I don't do much real programming, but I've recently been turned on to Atom, which has linter plugins for over 50 languages to make coding easier (most drawing on pre-existing lint-like programs).

In other languages, linters help me learn about operator precedence (unnecessary parentheses), good programming styles/techniques, and get warnings about code that may not have been intended. Is there something along these lines for Mathematica?

If not, is there a reason why not? At first glance it seems like a number of the suggestions/tips I pick up from reading answers here could be automated. For example, maybe the Mathematica linter would remind you to memoize your functions with f[n_]:=f[n]= if that setting is turned on.

Edit: For a couple days in November 2016 there was work on a linter for Atom for Mathematica on github, but the project seems to have died quickly and I couldn't get it to work.

  • 2
    $\begingroup$ I wonder if you could make something like this get your features? mathematicaplugin.halirutan.de $\endgroup$ – Moo Apr 16 '16 at 12:11
  • 1
    $\begingroup$ How is this different from the little popups that appear over each command when you hover the mouse? Or the "context sensitive" help? $\endgroup$ – bill s Apr 16 '16 at 14:14
  • 1
    $\begingroup$ Like bill s I would say that a very strong capability along the lines you describe already exists in Mathematica. $\endgroup$ – m_goldberg Apr 16 '16 at 15:42
  • 8
    $\begingroup$ I don't know of one, but it would be cool to have warnings for private symbols that start with an uppercase letter, implicit multiplications at line boundaries, and unlocalized iterator variables in Table constructs within functions (just to name the first few ideas that popped into my head). The pitfalls post would be an excellent source of inspiration for checks to implement. I wonder if a bit of spelunking would turn up a way to extend the front-end's existing bare-bone checks? $\endgroup$ – WReach Apr 16 '16 at 16:03
  • 1
    $\begingroup$ @WReach Ideally this is what Workbench would do if version 3 ever comes out of beta. $\endgroup$ – Edmund Apr 16 '16 at 22:34

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:

In[1]:= PacletInstall["CodeParser"]
Out[1]= PacletObject[CodeParser,1.0,<>]

In[2]:= PacletInstall["CodeInspector"]
Out[2]= Paclet[CodeInspector,1.0,<>]

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]";

Use CodeInspect to get a List of InspectionObjects:

lints = CodeInspect[code];

The 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.

summary of code linting

It is possible to also scan files with by doing CodeInspect[File[file]]

Both the parser and linter are open-sourced here:



I hope you enjoy using them!

  • 4
    $\begingroup$ When you solicit the community, you may want to look at things like the current "hot meta post" Linting - Code analysis for bugs, errors and style issues in the Wolfram Language $\endgroup$ – Mark S. Mar 6 '19 at 1:38
  • 2
    $\begingroup$ I figured out that LintFileReport does not give me all results because of the "SeverityExclusions" option, so that was an easy fix. Other comments: please support file names wrapped in File, and please add file name auto-completion to LineFile. $\endgroup$ – Szabolcs Mar 6 '19 at 11:03
  • 4
    $\begingroup$ And, of course, the first thing I should have said is that having these tools is really great! Thanks for all your work. :-) $\endgroup$ – Szabolcs Mar 6 '19 at 19:24
  • 5
    $\begingroup$ Big +1, Have you considered putting it e.g. on GitHub? @Szabolcs would have more space for issues :) $\endgroup$ – Kuba Mar 6 '19 at 22:35
  • 5
    $\begingroup$ The CodeInspector has now been made available on GitHub: github.com/WolframResearch/codeinspector $\endgroup$ – brenton Apr 8 '20 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.