typos/docs/about.md

66 lines
4.2 KiB
Markdown
Raw Normal View History

2019-07-03 21:22:36 -04:00
# About `typos`
## Design Requirements
Spell checks source code:
- Requires special word-splitting logic to handle situations like hex (`0xDEADBEEF`), `c\nescapes`, `snake_case`, `CamelCase`, `SCREAMING_CASE`, and maybe `arrow-case`.
- Each programming language has its own quirks, like abbreviations, lack of word separator (`copysign`), etc
- Backwards compatibility might require keeping misspelled words.
- Case for proper nouns is irrelevant.
Checking for errors in a CI:
- No false-positives.
- On spelling errors, sets the exit code to fail the CI.
Quick feedback and resolution for developer:
- Fix errors for the user.
- Integration into other programs, like editors:
- `fork`: easy to call into and provides a stable API, including output format
- linking: either in the language of choice or bindings can be made to language of choice.
## Design Trade Offs
2019-07-03 21:22:36 -04:00
### typos uses a blacklist
Blacklist: Known typos that map to their corresponding word
- Ignores unknown typos
- Ignores typos that follow c-escapes if they aren't handled correctly
Whitelist: A confidence rating is given for how close a word is to one in the whitelist
- Sensitive to false positives due to hex numbers and c-escapes
- Traditional spell checkers use a whitelist.
## Related Spell Checkers
2019-10-25 08:15:40 -04:00
See also [benchmarks](../benchsuite/runs).
2019-07-13 20:45:36 -04:00
| | typos | [bloom42/misspell][misspell-rs] | [client9/misspell][misspell-go] | [codespell] | [scspell3k] |
|----------------|-----------------------|---------------------------------|---------------------------------|-------------|-------------|
2019-10-25 10:06:05 -04:00
| Runtime | \- | \- | \- | Python | Python |
2019-07-13 20:45:36 -04:00
| Dictionary | Blacklist | Blacklist | Blacklist | Blacklist | Whitelist |
2020-11-10 07:40:24 -05:00
| Custom Dict | Yes | No | ? | Yes | Yes |
2021-04-06 22:18:56 -04:00
| Per-Lang Dict | Yes | No | ? | No | Yes |
2019-07-13 20:45:36 -04:00
| CamelCase | Yes | No | ? | No | Yes |
| snake_case | Yes | No | ? | No | Yes |
| Ignore Hex | Yes | No | ? | No | Yes |
2019-07-13 20:45:36 -04:00
| C-Escapes | No ([#20][def-3]) | No | ? | No | Yes |
| Encodings | UTF-8 / UTF-16 | UTF-8 | ? | Auto | Auto |
2019-07-13 20:45:36 -04:00
| Whole-project | Yes | Yes | Yes | Yes | No |
| Ignores hidden | Yes | Yes | ? | Yes | No |
| Respect gitignore | Yes | Yes | ? | No | No |
2019-07-18 22:20:45 -04:00
| Checks filenames | Yes | No | ? | Yes | No |
| Status via exit code | Yes | No | Yes | Yes | Yes |
2019-07-13 20:45:36 -04:00
| API | Rust / [JSON Lines] | Rust | ? | Python | None |
| License | MIT or Apache | AGPL | MIT | GPLv2 | GPLv2 |
[JSON Lines]: http://jsonlines.org/
[scspell3k]: https://github.com/myint/scspell
[misspell-rs]: https://gitlab.com/bloom42/misspell
[misspell-go]: https://github.com/client9/misspell
2019-07-13 20:45:36 -04:00
[codespell]: https://github.com/codespell-project/codespell
2019-10-25 10:06:05 -04:00
[def-9]: https://github.com/crate-ci/typos/issues/9
[def-14]: https://github.com/crate-ci/typos/issues/14
[def-17]: https://github.com/crate-ci/typos/issues/17
[def-18]: https://github.com/crate-ci/typos/issues/18
[def-3]: https://github.com/crate-ci/typos/issues/3