I am a developer at Wolfram Research and I have been working on linter technology that I think would be nice to share publicly.
There are 2 paclets on the public paclet server that you can download and use for finding problems with WL code.
CAVEAT: These paclets are experimental and not yet fully-formed, but they are constantly being worked on.
The two paclets you will need are AST and Lint:
The AST paclet provides functions for parsing WL code and returning syntax trees with interesting metadata attached, such as file and line information.
The Lint paclet uses AST and provides functions for scanning WL code and finding problems and reporting them.
Here is a demo of using the Lint paclet.
First, load the Lint` package:
Next, take a snippet of code that you are interested in linting.
code = "Which[a, b, a, b]";
LintString to get a
lints = LintString[code];
Lint objects are interesting by themselves, but it would be nice to see them formatted within lines of the source code.
LintStringReport[code, lints] // Column
The report shows formatted lines that you can mouse over to see the problem descriptions.
I included a screenshot to better show the result.
It is possible to also scan files with
The linter is very rudimentary right now, but it is constantly improving. It has already proven useful internally. Eventually I would like to solicit the community for more ideas for rules for the linter. I hope you enjoy using it!