Add --min-word-length option to ignore short words - #3971
Conversation
Words shorter than the given length are dropped from the misspelling dictionary up front, so they are ignored both in file contents and with --check-filenames. This avoids having to list every short variable name in --ignore-words-list. Closing: codespell-project#2211
|
Applied this branch and exercised it rather than just reading it — it works, and filtering at the dictionary level is the right layer. Sharing the checks in case they're useful to a maintainer: The one thing I went looking for was whether Filtering the dictionary once after For context on the size of what it buys: 162 of the default dictionary's keys are ≤3 characters, so (Not a maintainer, just a contributor who was recently in this file.) |
|
Gentle ping on this one — it's been about four weeks, so I wanted to check it hadn't just slipped off the radar. One thing that may be worth a maintainer's attention: the GitHub Actions workflows on this PR have never actually run. All five runs on the head commit ( It isn't specific to this PR: there are currently 42 runs in For context, this closes #2211, which is labelled The same gate applies to #3972 and #3973 if they're being triaged together. Happy to rebase, split this up, or take a different approach if you'd prefer it done another way — just let me know. |
Closes #2211
Adds a
--min-word-length LENGTHoption so that words shorter than LENGTH are not checked. This helps with codebases full of 2-3 letter variable names that would otherwise each need an entry in--ignore-words-list.Implementation: entries shorter than LENGTH are dropped from the misspelling dictionary right after it is built, so short words are ignored consistently everywhere (file contents, stdin and
--check-filenames) with no per-word cost during scanning. The default (0) keeps current behavior.Example:
Tests included (
test_min_word_length) covering the length boundaries, case-insensitivity and--check-filenames.