Skip to content

Round 3 follow-up: further split _search_term_filters() in users/admin.py - #559

Merged
mzeier merged 1 commit into
stage-eksfrom
450/py-r3-users-s3776-followup
Oct 10, 2026
Merged

mzeier merged 1 commit into
stage-eksfrom
450/py-r3-users-s3776-followup

Conversation

@mzeier

@mzeier mzeier commented Oct 10, 2026

Copy link
Copy Markdown

Part of #450 (round 3).

Sonar issue: python:S3776, users/admin.py:41, complexity 17.

My earlier extraction in thunderbird/addons-server#546 (merged) moved get_search_results()'s complexity into a new _search_term_filters() module function, but that function itself got re-flagged by Sonar at complexity 17 (higher than the original 16!) once re-analyzed on stage-eks after merge. Caught this by re-pulling OPEN issues for users/ before starting other work there, per the round-3 brief's "re-pull before each file" rule.

Split it further into _search_separator_and_operator(), _build_search_filters(), and _any_lookup_needs_distinct(), plus an early return when search_fields/search_term are empty (matching the original's effective behavior, since the old guard conditions were equivalent to a no-op in that case - use_distinct/filters/joining_operator were never mutated from their initial values when that branch wasn't taken).

No behavior change: verified the early-return path returns the exact same ([], False, operator.and_) that the original's untouched initial values would have produced.

Also confirmed via re-pull that users/backends.py (2x S1172 kw, 1x S1172 request) and users/models.py/users/widgets.py findings are already-documented exclusions from earlier rounds, not touched here.

Local Greptile review: org free-tier quota exhausted, skipped per coordinator guidance; the Greptile GitHub check on this PR still runs independently.

…n.py

My earlier extraction in #546 (merged) moved get_search_results()'s
complexity into a new _search_term_filters() module function, but that
function itself was re-flagged by Sonar at complexity 17 (even higher
than the original 16) once re-analyzed on stage-eks. Split it further
into _search_separator_and_operator(), _build_search_filters(), and
_any_lookup_needs_distinct(), plus an early return when search_fields/
search_term are empty (matching the original's effective behavior,
since the old guard conditions were equivalent to a no-op in that case).

No behavior change: verified the early-return path returns the exact
same (empty filters, False, operator.and_) that the original's
untouched initial values would have produced when the outer `if
search_fields and search_term:` was false.
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Python Test Results

5 763 tests  +5 763   5 709 ✅ +5 709   7m 31s ⏱️ + 7m 31s
    1 suites +    1      54 💤 +   54 
    1 files   +    1       0 ❌ ±    0 

Results for commit 72cdc20. ± Comparison against base commit 6d0c585.

@mzeier
mzeier merged commit 15c0805 into stage-eks Oct 10, 2026
3 checks passed
@mzeier
mzeier deleted the 450/py-r3-users-s3776-followup branch October 10, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant