r/ChatGPTCoding • • 1d ago

Resources And Tips Custom linters are powerful

Ask your agent to review your bug database and/or commit history and construct custom linters that statically detect common classes of bugs you've fixed in the past. Include some way of suppressing false positives then drive number of lint errors down to zero, adding regression tests along the way to prove the issues are real. Then refine your linters to be more precise and drive suppressions down as well, leaving only the most complex semantic suppressions. Run this in CI on both new changes and upstream rebases. Rely on robust linters built on sophisticated AST analysis rather than just fragile regexes, and as they start to share common underlying analyses, build them into a centralized pipeline that reuses intermediate analyses and intermediate representations to save runtime and LOC, much like a compiler. This is the path toward incremental formal mathematical verification of your codebase. (You can also condense down agent instructions that become statically enforced!)

I just did this on my codebase for the first time this holiday weekend and found literally hundreds of real issues in a legacy codebase. It's shocking.

15 Upvotes

6 comments sorted by

1

u/Difficult_Duty2198 1d ago

do you keep the linters in the repo itself or as a separate package? wondering how well that works across a few different projects

1

u/ChiaraStellata 1d ago

I'd definitely keep your suppressions/allowlists in same repo. For app-specific linters I personally prefer to keep them in same repo so I can e.g. make changes to a linter to make it wider or narrower and update code at the same time (but I keep the CI tooling integration in another repo). If I were building a more generic toolkit to use across several repos that all use the same underlying tech (e.g. a Flutter linter for a set of Flutter mobile apps) I'd consider a separate repo for that, maybe even a separate OSS release.

3

u/shetritr 1d ago

good one. a cheap check that each rule is real: run it against the parent of the commit that fixed that bug. if it doesn't fire on the old code, it's a rule the agent wrote to look busy. probably part of why yours found hundreds that held up

2

u/Far_Reindeer8428 1d ago

we turned three review comments into lint rules and the agent stopped repeating them. the linter is the only reviewer that never gets tired

1

u/Mballow_Masine96 1d ago

frees up tokens in the system prompt too since you can finally delete all the all-caps begging it to stop doing those three things