Skip to content

fix(analytics): code smell counts derive from the returned list, shared root-relative discovery (#20493) - #21002

Closed
mrveiss wants to merge 3 commits into
mainfrom
issue-20493-code-smell-scope
Closed

mrveiss wants to merge 3 commits into
mainfrom
issue-20493-code-smell-scope

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

The cards and the list disagreed and the scan looked shallow. Discovery was already recursive; the divergences were the exclusion rule and counts stored apart from the list.

What Changed

Refs #20493. Code-smell results and their counts came from different sets, and the two discovery paths excluded files by different rules.

  • Counts: AnalysisReport.to_dict returned stored summary/severity_distribution while the endpoint replaced anti_patterns after a severity filter, so the cards and the list described different sets. They are now counted from the returned list.
  • Discovery: the uncached collector matched excluded names against the absolute path, so a tree below a directory named like a skip dir scanned as empty; the cached path matched root-relative. Both now use one is_excluded predicate in code_intelligence/python_files.py.
  • One exclusion rule: the shared file cache pre-filters with the fixed SKIP_DIRS, so the cached path is used only when exclude_dirs covers SKIP_DIRS (cache_covers_exclusions); otherwise discovery walks. exclude_dirs stays authoritative and both paths return the same set. An out-of-root path is treated as excluded, as is_skipped_path does. cap_applied is a report field set by the discovery code (False), and the unreachable report.summary fallback in the cache writer is removed.
  • Scope: the report states files_examined, files_failed and cap_applied (no cap applies to discovery).

Not delivered, so the issue stays open: AC3 (one defect counted once across long_function and code_smell_long_method), AC4 (test files separated), AC5 (triage), and the status of a killed indexing run (stored partial findings shown as a result), which is a separate defect.

Single-issue rationale: one defect (report counts and discovery scope in the code-smell analyzer) fixed in one place.

Verification

  • anti_pattern_scope_20493_test.py: nested fixture control, nested files scanned, cached and uncached discovery agree, root below an excluded name, summary equals list, scope stated, files_failed == 1 on the cached path, custom exclude_dirs agreeing across both paths, out-of-root exclusion.
  • Neighbouring tests (including the delegate test) pass with the neighbouring anti-pattern and delegate tests.

Model Used

Claude Sonnet 5.5

…overy is root-relative and shared, scope is stated (#20493)
@mrveiss mrveiss added bug Something isn't working phase:M4.11 Safety net: tests and analysers reach the whole tree labels Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 22097e0 and 2f0bfaa.

Files ignored due to path filters: 1

  • scripts/python_file_size_known_large.py is excluded by !scripts/python_file_size_known_large.py
Files selected for processing: 4

  • autobot-backend/code_intelligence/anti_pattern_detection/analyzer.py
  • autobot-backend/code_intelligence/anti_pattern_detection/models.py
  • autobot-backend/code_intelligence/anti_pattern_scope_20493_test.py
  • autobot-backend/code_intelligence/python_files.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) at 82f3c69 — APPROVE

Check Result
Correctness: exclusion is_excluded matches on parts below the scan root, so a tree under a directory named like an excluded name is no longer scanned as empty; a path outside the root is treated as excluded (documented). collect_python_files is shared with the clone detector and pattern analyzer, so they get the same fix.
Cached vs uncached agreement Cache is used only when SKIP_DIRS <= exclude_dirs (cache_covers_exclusions); the default DEFAULT_IGNORE_PATTERNS includes all of SKIP_DIRS, so the default path still uses the cache. A custom exclude_dirs omitting a skip name walks instead. Both covered by tests.
Counts from one list summary/severity_distribution/total_issues in to_dict and the async result are counted from anti_patterns, so a filtered list cannot disagree with its counts. The health endpoint still reads the unfiltered stored distribution, which matches its unfiltered list.
Scope stated files_failed counts both exceptions and unparseable files on both paths; files_examined = total_files - files_failed.
Tests fail without the change test_root_below_an_excluded_name_is_still_scanned, the custom-exclude agreement test and the summary-after-filter test fail on main.
Swallowed errors / sleeps / loggers / size Failures are now counted and reported (still logged at debug as before). analyzer.py is 746 lines and the known-large entry was lowered to match; the new test file is 97.

Nits, not blocking:

  • cap_applied is a constant False on a path that has no cap; it states a negative rather than measures one. Fine as a contract field, but drop it if nothing reads it.
  • report.summary / report.severity_distribution are still computed in _create_analysis_report but no longer used by to_dict; only the health endpoint reads the latter. Worth a follow-up to remove the duplicate computation.

@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Landed on main via merge train #21031 (merge commit 361d419); every commit of head 82f3c69 is in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working phase:M4.11 Safety net: tests and analysers reach the whole tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant