Comments (16)
@bittorf there isn't a way to do that right now. I think it would be reasonable to add a new option to pass a file with "ignore-words", or to extend the dictionary format to allow passing words as good ones.
For the first option it would be something like:
codespell --ignore-words /path/to/good/dictionary.txt
While for the second we would support in the dictionary a syntax like:
-churchs
So you could use something like thi:
codespell -D - -D /path/to/dictionary/extensions/including/good/words
@anatol @pabs3 @Eric89GXL @thdot thoughts
from codespell.
I agree with Lucas, adding comments into the code to influence codespell isn't a sustainable way. Personally I like the idea to extend the dictionary syntax, but a word exclude file is fine for me as well.
@bittorf: if you want to ignore just one occurrence of "churchs" I think the --exclude-file
option is a good way to achieve that.
from codespell.
I'm not quite sure why this example doesn't follow the pattern:
echo "DotA" | codespell -L DotA -
I get an error that is seemingly inextinguishable.
Try this @alex-zenml :
echo "DotA" | codespell -L dota -
-L WORDS, --ignore-words-list WORDS
comma separated list of words to be ignored by
codespell. Words are case sensitive based on how they
are written in the dictionary file
@bittorf we've also got this now:
-x FILE, --exclude-file FILE
FILE with lines that should not be checked for errors
or changed
The issue with comment directives, is e.g. you can't do them within some Pydoc or a Doxygen block or whatever (so it can't always be the line before), and you can then never write codespell ignore=
without it ignoring something, i.e. you can't ever write a comment about that behaviour.
from codespell.
You could use the --exclude-file
option to exclude the lines containing the good word explicitly.
Not the most elegant way, I know.
from codespell.
a more elegant solution would be a comment-statement in the line with e.g.
codespell: churchs
from codespell.
@lucasdemarchi that is not the way i like it:
the given example is real ("churchs") but of course i do not want
to loose real occurences of a misspelled "church". think of a large file,
where only 1 thing should be overridden...
from codespell.
from codespell.
@thdot - i can work with the --exclude-file approach, but it is not elegant. having statements in the file is an old and good way to talk with a compiler. see e.g. GCC or 'shellcheck': https://github.com/koalaman/shellcheck/wiki/Directive
having extra files describing an issue feels like code duplication. what is if a line moves up or down? i have to tweak my 2nd file also...
from codespell.
please integrate a codespell --ignore-words /path/to/good/dictionary.txt
from codespell.
Fixed by #100
from codespell.
i still think, that a 'directive' directly above the false positive would be a better solution, e.g.
...
# codespell ignore=churchs
echo "a wrong word: churchs (a shoebrand) and a good word: churches"
...
codespell does not need knowledge about how to detect comments in language XY:
it only must check, if in the line above is a directive "codespell ignore=..."
from codespell.
@bittorf
use the -L
flag. Try this:
echo "churchs, churches" | codespell -L churchs -
then try
echo "churchs, churches" | codespell -
from codespell.
The L flag is not enough:
This way you ignore the wrong word "churchs" in the whole file.
Having a "directive" in the file, you can ignore just a single occurrence
and the knowledge about this special situation is directly at the correct place.
from codespell.
I agree, a directive would be great! I want to be specific about where to ignore what.
from codespell.
@bittorf use the
-L
flag. Try this:echo "churchs, churches" | codespell -L churchs -
then tryecho "churchs, churches" | codespell -
I'm not quite sure why this example doesn't follow the pattern:
echo "DotA" | codespell -L DotA -
I get an error that is seemingly inextinguishable.
from codespell.
just an update that since #2400 it's now possible to add inline ignore comments.
from codespell.
Related Issues (20)
- question: how to print filename of the file being processed?
- Support namespaced dictionary packages HOT 1
- "Goverment" not regonized in all relevant lines HOT 2
- support ignore for blocks of code HOT 1
- Codespell Not Ignoring Words Properly when Provided in Original Case HOT 1
- release a new version ? HOT 15
- Unable to add inline comments for markdown documents HOT 7
- Splitting multiple 'skip' paths onto indented config file lines behaves differently than when on a single line HOT 4
- Are inline ignores restricted to hash-style comments? HOT 1
- Is it possible to combine a custom dictionary with a builtin dictionary? HOT 1
- pre-commit to remove `Used config files:` noisy output HOT 1
- Python API support HOT 7
- Better control over decoding problems reporting HOT 2
- Codespell inline ignores don't appear to work in Markdown files HOT 3
- assertIn false positivies HOT 9
- Better project description HOT 3
- Tests fail if not 'codespell' installed HOT 5
- I need to ignore "image/png" the contents of the ipynb(python) file / .pre-commit-config.yaml HOT 3
- false positive: unparseable HOT 6
- Unable to Ignore Files Completely Using .codespell.toml Configuration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codespell.