vscode-matlab
vscode-matlab copied to clipboard
Consider using severity argument to mlint executable
Saw the great addition by @RobinTournemenne in https://github.com/Gimly/vscode-matlab/pull/106
There is an undocumented -severity
flag to mlint
that returns a severity number:
$ mlint -id -severity f.m
L 2 (C 3): NOPRT: ML0: Terminate statement with semicolon to suppress output (in functions).
the ML0
. Those are the numbers documented in:
https://stackoverflow.com/questions/35898444/find-category-of-matlab-mlint-warning-id/36058284
Creating this issue in case someone wants to switch to using that. Some caveats:
-
-severity
is undocumented and unsupported so it will likely change behavior in the future -
-severity
was added in R2016b. Using it in a release older than that you'll get an extra error:
$ mlint -id -severity f.m
L 0 (C 0): BDOPT: Option '-severity' is ignored because it is invalid.
L 2 (C 3): NOPRT: Terminate statement with semicolon to suppress output (in functions).
Hahaha XD. The time I spent checking every linting message... Well could keep my solution with a if statement as long as Matlab has this -severity flag. I am not even sure it is a good idea because I do think Matlab will keep this -severity flag.
I think I could add a switch in the config file, like that we can keep both your implementation which will work for all versions, even pre R2016b, and a new one with the flag. This way even if they remove it in a future version we will still have a fallback.
Seems good to me.
It appears the older way of doing this is the -m0
, -m1
, -m2
, and -m3
flags, in order of increasing severity. Some additional parsing would have to be done, because -m0
returns (less severe?) warnings and everything from -m1
as well.
Found this article from 2013 while looking for other stuff, and was about to open an issue to bring it your attention: http://undocumentedmatlab.com/articles/parsing-mlint-code-analyzer-output The article is about parsing output within MATLAB, but all the options I've tried so far work with the command line version of mlint
.