フィルターのクリア

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

4 ビュー (過去 30 日間)
Tom Hawkins
Tom Hawkins 2019 年 1 月 24 日
コメント済み: Santtu Söderholm 2023 年 5 月 22 日
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.

回答 (1 件)

Santtu Söderholm
Santtu Söderholm 2023 年 5 月 14 日
編集済み: Santtu Söderholm 2023 年 5 月 14 日
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 件のコメント
Tom Hawkins
Tom Hawkins 2023 年 5 月 16 日
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 2023 年 5 月 22 日
@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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by