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.
The two paclets you will need are CodeParser and CodeInspector:
The CodeParser paclet provides functions for parsing WL code and returning syntax trees with interesting metadata attached, such as file and line information.
The CodeInspector paclet uses CodeParser and provides functions for scanning WL code and finding problems and reporting them.
Here is a demo of using the CodeInspector paclet.
First, load the CodeInspector` package:
Next, take a snippet of code that you are interested in linting.
code = "Which[a, b, a, b]";
CodeInspect to get a
lints = CodeInspect[code];
InspectionObjects are interesting by themselves, but it would be nice to see them formatted within lines of the source code.
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 by doing
Both the parser and linter are open-sourced here:
I hope you enjoy using them!