Skip to content

fix: positional path arg for quality/hotspots, deduplicate hotspots, suppress sarif import noise#14

Merged
M9nx merged 4 commits intoM9nx:mainfrom
nandanadileep:fix/quality-hotspots-sarif-errors
Apr 8, 2026
Merged

fix: positional path arg for quality/hotspots, deduplicate hotspots, suppress sarif import noise#14
M9nx merged 4 commits intoM9nx:mainfrom
nandanadileep:fix/quality-hotspots-sarif-errors

Conversation

@nandanadileep
Copy link
Copy Markdown
Contributor

@nandanadileep nandanadileep commented Apr 5, 2026

Fixes #12 and #13.

Changes

codexa quality . / codexa hotspots . now work (fixes #13)

Both commands previously defined --path as the only way to set the project root. Passing a bare path like . caused Click to reject it with Got unexpected extra argument (.).

Each command now accepts an optional positional DIRECTORY argument. Both of these are equivalent:

codexa quality .
codexa quality --path .

Duplicate hotspot entries de-duplicated (fixes #13)

analyze_hotspots was scoring every Symbol object from get_all_symbols() independently. If the same function was parsed or indexed more than once, it appeared multiple times in the output with identical scores (e.g. test_to_dict repeated in tests/test_phase20.py).

Symbols are now deduplicated by (file_path, name) before scoring, so each unique symbol appears exactly once.

Spurious SARIF error suppressed (fixes #12)

Bandit eagerly loads all its formatters at import time, including a SARIF formatter that requires the optional sarif_om package. When sarif_om is absent, bandit emits:

ERROR    Could not load 'sarif': No module named 'sarif_om'

This appeared on every codexa quality / codexa hotspots run regardless of whether SARIF output was requested.

The fix adds a temporary logging.Filter to the bandit logger around the import, removing it immediately after. Genuine bandit errors are still surfaced; only this specific optional-dependency message is suppressed.

Test plan

  • codexa quality . runs without "Got unexpected extra argument" error
  • codexa hotspots . runs without "Got unexpected extra argument" error
  • codexa quality --path . still works (backward compatible)
  • codexa hotspots output shows each symbol at most once
  • No ERROR Could not load 'sarif' message on codexa quality without sarif_om installed
  • codexa quality --sarif (if/when added) still shows a clear hint when sarif_om is missing

…if error

Fixes M9nx#12 and M9nx#13.

- quality/hotspots: accept an optional positional DIRECTORY argument so
  'codexa quality .' and 'codexa hotspots .' work without --path.
  Previously Click rejected the bare '.' with 'Got unexpected extra
  argument (.)'.

- hotspots: deduplicate callable_symbols by (file_path, name) before
  scoring so that re-indexed or multiply-parsed symbols do not produce
  repeated entries in the hotspot list with identical scores.

- quality: suppress the 'Could not load sarif: No module named sarif_om'
  ERROR that bandit logs on every import when the optional sarif_om
  package is not installed.  The filter is applied only during bandit's
  import and removed immediately after, so genuine bandit errors are
  still surfaced.
@M9nx M9nx self-assigned this Apr 5, 2026
@M9nx M9nx added bug Something isn't working enhancement New feature or request labels Apr 5, 2026
@M9nx M9nx requested review from M9nx and Copilot and removed request for M9nx April 5, 2026 18:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes codexa quality / codexa hotspots CLI ergonomics and reduces noisy output by accepting a positional directory argument, deduplicating hotspot symbol entries, and suppressing an optional Bandit SARIF import log.

Changes:

  • Add optional positional DIRECTORY argument to codexa quality and codexa hotspots (while keeping --path).
  • Deduplicate hotspot scoring inputs to avoid repeated entries for the same symbol.
  • Suppress Bandit’s “Could not load 'sarif'” log during import when sarif_om is not installed.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
semantic_code_intelligence/cli/commands/quality_cmd.py Adds optional positional directory arg and uses it to select the analysis root.
semantic_code_intelligence/cli/commands/hotspots_cmd.py Adds optional positional directory arg and uses it to select the analysis root.
semantic_code_intelligence/ci/quality.py Adds a temporary logging filter around Bandit import to suppress SARIF optional-dependency noise.
semantic_code_intelligence/ci/hotspots.py Deduplicates callable symbols before scoring to prevent repeated hotspot entries.

@M9nx
Copy link
Copy Markdown
Owner

M9nx commented Apr 5, 2026

Hi @nandanadileep , Appreciate the fix and improvements here. Changes look solid and tested — proceeding to close this PR. Thanks!

@M9nx M9nx self-requested a review April 5, 2026 21:57
M9nx and others added 3 commits April 8, 2026 09:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@M9nx M9nx merged commit 5555066 into M9nx:main Apr 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

3 participants