Skip to content

refactor: close the last three Sonar issues the capture cleanup left open - #313

Merged
ffroliva merged 2 commits into
mainfrom
refactor/sonar-last-three
Nov 24, 2026
Merged

ffroliva merged 2 commits into
mainfrom
refactor/sonar-last-three

Conversation

@ffroliva

Copy link
Copy Markdown
Owner

Summary

Three open code-scan issues on main that #310 meant to close and did not:

Issue Change Cognitive complexity (complexipy)
python:S3776 engine/probe.py run_probe (24) the ASGI receive/send pair moves into a _Channel class and the host call into _invoke_host; the order of checks, the timeout path and the slot release are unchanged run_probe 13, _Channel.send 4, _invoke_host 2
python:S3776 engine/capture/sqltrace.py SqlTraceRecorder.record (17) the locked store block moves into _store, same statements in the same order under the same lock record 14, _store 3
python:S107 engine/capture/exchanges.py exchange_row (17 parameters) the existing suppression moves to the line the issue is reported on (the first parameter); it was on the def line, so it never applied —

exchange_row keeps its suppression: its 17 keyword-only arguments are the fields of one flat row, built once per request on the capture hot path, where a parameter object would add an allocation per request.

tests/complexity_baseline.json: src/sharpit/engine/probe.py 1 → 0 (no C901 finding left). sonar-baseline.txt → 8, main's open count.

Verification

  • ruff check, ruff format --check, pyright on the changed modules.
  • pytest -n 4 over probe, HTTP probe, pentesting probes, health, tests/engine/capture, SQL trace API, tests/masking, code shape and import boundary: passed except test_complexity_only_goes_down (pin lowered above).
  • Overhead budgets run alone (-n 0): test_statement_overhead_budget_on_a_full_ring passed three of three on this branch; the same test on main failed one of three on the same machine (51.3 µs against 50 µs), so that failure is machine load.

Contribution Checklist

  • Every non-merge commit carries Signed-off-by.
  • No AI attribution.
  • No new suppression: the exchange_row one moved one line.

…exity limit; put the exchange_row suppression on its reported line

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
@ffroliva
ffroliva merged commit b403cbe into main Nov 24, 2026
50 checks passed
ffroliva added a commit that referenced this pull request Nov 24, 2026
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
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