Where do I find the list of possible messages and IDs returned by checkcode?

3 views (last 30 days)
For my company's software quality process, I need to determine and report the number of 'blocking' and 'critical' quality violations in my MATLAB code.
The standard tool we use for this (Sonar Qube) doesn't support MATLAB and there doesn't seem to be a built-in way of doing it in the MATLAB IDE, so I've written a short script that runs checkcode on each .m file in the project folder structure and compiles the output into a report. The struct output from checkcode includes a short text ID for each message, for example AGROW is The variable (name) appears to change size on every loop iteration. Consider preallocating for speed.
I want to categorise each message as blocking, critical or non-critical according to a coding standard that we will set, so that I can count up how many messages fell into each category. Can I get a complete list of the possible messages and their IDs, for any given version of MATLAB? There's nothing in the checkcode help, and the settings file saved from the Code Analyzer preferences doesn't seem to contain this information.

Answers (1)

Santtu Söderholm
Santtu Söderholm on 14 May 2023
Edited: Santtu Söderholm on 14 May 2023
Since all linter tools provided by Matlab, such as mlint, checkcode and since R2023A codeIssues, ultimately fall back onto the Code Analyzer, the documentation related to linting messages can be found on the index page for Code Analyzer checks (link).
  2 Comments
Tom Hawkins
Tom Hawkins on 16 May 2023
Thanks for your reply Santtu! I think I did find an unsupported method for listing all Code Analyzer messages programmatically, but in the end I went with the approach of explicitly defining in my script which messages could be ignored and which were 'critical', and assuming any other message was 'blocking'. If any new 'blocking' message arises which should be critical or ignored that then needs a documented change to the quality reporting script, but that's not a frequent occurrence so not a problem for my project.
Santtu Söderholm
Santtu Söderholm on 22 May 2023
@Tom Hawkins I ended up writing a little web scraper (link), that fetches all of the messages and their severities from the MathWorks website and prints them to standard output, from which they can be redirected to a CSV file:
python3 -m pip install -r requirements.txt
python3 run.py > matlab-linter-messages.csv
The column separator is the (unadjustable) ASCII unit separator character , which is a bit unstandard, but I wanted to avoid clashes with commas and other typical CSV delimiters.

Sign in to comment.

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!