Skip to content

Add --report-unused-ignore-words option#3972

Open
ekanshul wants to merge 1 commit into
codespell-project:mainfrom
ekanshul:report-unused-ignore-words-2354
Open

Add --report-unused-ignore-words option#3972
ekanshul wants to merge 1 commit into
codespell-project:mainfrom
ekanshul:report-unused-ignore-words-2354

Conversation

@ekanshul

Copy link
Copy Markdown

Closes #2354

Ignore-words files tend to grow over time and nobody knows which entries are still needed. This adds a --report-unused-ignore-words option: at the end of the run, codespell prints (to stderr) the entries from --ignore-words/--ignore-words-list that never suppressed a misspelling in the checked files, so stale entries can be removed.

Semantics: an entry only counts as used when it actually suppresses a dictionary match. An ignore word that does not match any dictionary entry is reported as unused even if the word appears in the checked files — such an entry cannot suppress anything, which is exactly the "keep the file to what is currently being used" goal from the issue.

$ codespell --report-unused-ignore-words -I .codespell-ignore .
Unused ignore words: fdindigd, siz

The report is informational and does not change the exit code, following the reporting-oriented direction suggested in the issue discussion (a strict/failing mode could be layered on top later if wanted). There is no runtime overhead when the option is not used.

Notes:

  • max-args had to be bumped 13 → 14 in pyproject.toml: parse_lines/parse_file were already at the limit, and they need the (single, optional) usage-tracker argument.
  • Tests included (test_report_unused_ignore_words) covering -L, -I, cased entries, non-dictionary entries and --check-filenames.

Ignore words files tend to grow over time and nobody knows which
entries are still needed. With this option codespell reports, at the
end of the run, the entries from --ignore-words and
--ignore-words-list that never suppressed a misspelling in the checked
files, so stale entries can be removed.

An entry only counts as used when it actually suppresses a dictionary
match: an ignore word that does not match any dictionary entry is
reported as unused even if it appears in the checked files.

Closing: codespell-project#2354
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.

How to cleanup ignored words?

1 participant