DEV Community

yanlong wang
yanlong wang

Posted on

Grammar Checking Code Comments and Docstrings: Why It Matters (2026)

Code gets reviewed, refactored, and tested. Comments get written once and read for years. A docstring with "Returns the a user object" survives every code review — because reviewers read code, not prose.

Where Comment Errors Come From

  • Rushed commits — "fix typo" comments that themselves contain typos
  • Copy-paste refactors — docstring says getUserById, function is now getUserByEmail
  • Non-native English — article and tense errors that accumulate across a codebase
  • AI-generated stubs — plausible docstrings describing behavior the code does not have

Why Generic Grammar Checkers Fail Here

Run a docstring through a generic checker and it "fixes" the wrong things: userId becomes "user ID", None gets capitalized, kwargs gets flagged as a typo. No model of code means every identifier looks like a spelling mistake — which trains you to ignore the checker.

A code-aware checker like Lint does the opposite: identifiers, paths, and type annotations are skipped by design, so every suggestion applies to the prose around the code.

A 10-Minute Comment Cleanup Ritual

  1. Grab all comments/docstrings into one buffer, run a code-aware grammar check with a diff view
  2. Check docstrings against behavior — stale docstrings are worse than typos
  3. Normalize terminology ("username" or "user name", not both)
  4. Fix tense and articles

Comments are documentation with the highest read-to-maintenance ratio in your repo.

👉 Try Lint free — 3 checks/day, no signup. BYOK: unlimited and $0.

Top comments (0)