-
Notifications
You must be signed in to change notification settings - Fork 195
Writing robust, performant linters
Michael Chirico edited this page Jul 27, 2023
·
12 revisions
The {lintr} codebase has a lot of accumulated knowledge about how to write robust and fast linters. This Wiki exists as a repository for tidbits on these topics.
It exists as a Wiki to make editing it open to all and with low overhead.
- When writing a test for logical constants like
TRUEorFALSE, if you want the condition to match the shorthandsTandF, note that the former is aNUM_CONSTwhile the latter is aSYMBOL(c.f.getParseData(parse(text = "TRUE; T")))
- Avoid
//*like the plague! At least in the current {xml2}, it is almost always slower than alternatives. A good example is https://github.com/r-lib/lintr/pull/2025, which shows a 3x speed-up from avoiding//*even though the replacement is a long, inefficient-seeming chain of//A[expr] | //B[expr]-style repetitive expressions.