Skip to content

refactor: merge project checkers sharing keyword usage iteration - #1917

Merged
bhirsz merged 1 commit into
mainfrom
refactor/merge-project-checkers
Aug 26, 2026
Merged

refactor: merge project checkers sharing keyword usage iteration#1917
bhirsz merged 1 commit into
mainfrom
refactor/merge-project-checkers

Conversation

@bhirsz

@bhirsz bhirsz commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

Merges project checkers that iterate the same project data into single visitors, reusing one context.iter_usages() pass — mirroring the multi-rule VisitorChecker pattern already used elsewhere.

linter/checkers/usage.py

Combined three checkers that each looped over every keyword call into one KeywordUsageChecker handling all three rules:

  • KeywordNotFound + AmbiguousKeywordNames + MissingKeywordPrefixKeywordUsageChecker (keyword-not-found, ambiguous-keyword-name, missing-keyword-prefix)
  • UnusedKeywords left separate (it loops iter_files(), not iter_usages()).

linter/checkers/keyword_arguments.py

  • ProjectArgumentsChecker + ProjectArgumentNamesCheckerProjectArgumentsChecker (invalid-argument-count, missing-argument-name)

Notes

  • Each rule's work is guarded by a per-rule enabled flag, preserving the previous behavior where a checker only did expensive keyword resolution when its rule was selected (including the "skip when no library loader" short-circuit for keyword-not-found).
  • Per-usage decision logic stayed in the checkers via small _check_* helpers; the rules remain declarative.
  • No rule IDs, names, messages, or user-facing behavior changed.

Testing

  • Affected rule acceptance tests (keyword-not-found, ambiguous-keyword-name, missing-keyword-prefix, invalid-argument-count, missing-argument-name, unused-keyword) pass.
  • Full tests/project suite (179 tests) passes.
  • ruff check and mypy --strict clean.

Combine project checkers that each looped over every keyword call into single visitors reusing one context.iter_usages() pass, mirroring the multi-rule VisitorChecker pattern.

- usage.py: merge KeywordNotFound, AmbiguousKeywordNames and MissingKeywordPrefix into KeywordUsageChecker.

- keyword_arguments.py: merge ProjectArgumentsChecker and ProjectArgumentNamesChecker.

Per-rule enabled guards preserve the previous skip-when-disabled behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bhirsz
bhirsz merged commit 9c41a2a into main Aug 26, 2026
11 checks passed
@bhirsz
bhirsz deleted the refactor/merge-project-checkers branch August 26, 2026 07:35
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