Add --report-unused-ignore-words option#3972
Open
ekanshul wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2354
Ignore-words files tend to grow over time and nobody knows which entries are still needed. This adds a
--report-unused-ignore-wordsoption: at the end of the run, codespell prints (to stderr) the entries from--ignore-words/--ignore-words-listthat 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.
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-argshad to be bumped 13 → 14 inpyproject.toml:parse_lines/parse_filewere already at the limit, and they need the (single, optional) usage-tracker argument.test_report_unused_ignore_words) covering-L,-I, cased entries, non-dictionary entries and--check-filenames.