필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by