MA

MATLAB Code Analyzer

MATLAB Code Analyzer (mlint) and checkcode conventions for static analysis

Details

Language / Topic
matlabMATLAB
Category
Linter / Formatter

Rules

balanced
- Run `checkcode('myFile.m', '-cyc')` in CI to report lint warnings and cyclomatic complexity — fail builds with errors or complexity above 10.
- Suppress specific `mlint` warnings inline only when intentional: `%#ok<AGROW>` for dynamic array growth with a comment explaining why it is acceptable.
- Eliminate all `NASGU` (variable assigned but never used) and `ASGLU` (output suppressed with `;` but assigned) warnings — they indicate dead code.
- Enable real-time Code Analyzer feedback in the MATLAB Editor and resolve all orange and red underlines before committing — treat them as compiler warnings.
- Use `mlint` message IDs to suppress warnings project-wide in `mlint` settings files rather than scattering `%#ok` suppressions through the code.
- Address `MCSUP` (use of `i` or `j` as variable names shadowing the imaginary unit) warnings by renaming loop indices to `ii`, `jj`, `kk`.
- Refactor functions with cyclomatic complexity above 15 by extracting sub-functions or using lookup tables for multi-branch logic.