Skip to content

Migrating to the MATLAB-conformant malt ​

This page is for users of the earlier malt. The release was rebuilt around one rule: under its default configuration malt reports what MATLAB R2026b's Code Analyzer reports, and nothing else. The statements below come from the rule sources and from probing a real checkcode. The evidence for each is in docs/VERIFY.md, and How malt is verified explains how conformance is enforced.

Summary of changes ​

Correctness: every engine was rebuilt against a running MATLAB R2026b (checkcode): findings that MATLAB does not report were removed, findings it does report were added, message texts, severities, lines and columns were aligned, and %#ok suppression directives now follow MATLAB's rules. On the conformance fixtures, including four corpora of fresh files and MathWorks' own toolkit, malt now matches MATLAB with zero differences. If you lint the same project with the same config, the output will differ: there are fewer false positives, and different findings wherever the old heuristics guessed.

Defaults: the default is now MATLAB's factory configuration (mathworks preset): the checks MATLAB never reports by default are off, the 897 compatibility entries MATLAB marks low reliability are off, and the suggested-improvement hints (which MATLAB does report) are on. --preset all turns everything on again.

CLI: --fix is safe by default and --fix --unsafe-fixes opts into behaviour-changing rewrites; --fix now exits 1 when findings remain. New: --level, --color, -v/-vv, --strict-config, --index/--no-index. malt also reads MATLAB's own resources/codeAnalyzerConfiguration.json.

Config: unknown rule IDs and parameters in .malt.toml are now reported (use --strict-config to make them an error). The CUSTOM_CHECKS engine lost its numeric max_* misuses of the DAF* IDs (they are boolean disallow_* options now), NOSEMI changed meaning, and a handful of made-up checks were deleted.

NOSEMI now means the extra semicolon ​

beforenow
x = 1;;not reportedNOSEMI: extra semicolon is unnecessary
x = 1 (script)NOSEMI: trailing semicolon missingNOPTS: add a semicolon to hide the output (in a script)
y = f() (function)NOSEMINOPRT: add a semicolon (in a function)

The old NOSEMI ("trailing semicolon missing") duplicated what MATLAB reports as NOPTS/NOPRT. NOSEMI now carries MATLAB's meaning: the extra semicolon after x = 1;; is unnecessary. The rule takes no parameters: the ignore_functions option is gone, and a config that still sets it gets a warning (below).

--fix, --unsafe-fixes and the exit codes ​

  • Before: --fix applied every available fix in one pass, including rewrites that change behaviour, and always exited 0.
  • Now: --fix applies safe fixes only, repeating until nothing changes (a fix can enable another). Fixes that may change behaviour (str2num → str2double, a & b → a && b, …) are reported as N more with --fix --unsafe-fixes and applied only with that flag. Since the second curation pass --fix also applies FVAL, MSNU (deleting a %#ok directive that suppresses nothing), TWOCM, STRQUOT and FORMATNOI, with the text MATLAB's own fix writes.

Exit codes:

CodeMeaning
0No findings (with --fix: none remain after fixing)
1Findings reported (also with --fix when some remain)
2Runtime error, invalid config, or (with --strict-config) any config warning

CI scripts that treated malt --fix as always-green must now handle exit code 1, or pre-filter with --level. --level error (or warning) hides findings below the level. Hidden findings are not counted and do not set the exit code, and --fix still fixes them.

The Safe fixes were curated against MATLAB's own fix ​

--fix still applies only Safe fixes, but the set was re-curated with MATLAB's own codeIssues(...).fix(ID) as the oracle (see VERIFY.md, '5.5 Curated safe autofixes'). What changed for a plain --fix:

CheckBeforeNow
NOPTS, NOPRTinserted a ; in front of a comma, producing x = 1;, y = 2 (which the Code Analyzer itself reports as NOCOMMA)replaces the comma, as MATLAB's fix does (x = 1; y = 2;)
NBRAK2replaced the whole bracket expression with the element text, dropping comments inside the bracketsstrips only the two bracket tokens, keeping inner text, comments and spacing (MATLAB's fix is the same)
FLUDLRrot90(x, 2)rot90(x,2), byte-identical to MATLAB's fix
FNDEFno fixrenames the declaration to the file name, as MATLAB's auto fix does (Safe: the runtime resolves by file name)
DLABINDEX, DNUMLABS, DGOP, CAXIS, ISDIR and the other direct-replacement renamesno fixthe callee token is renamed (labindex → spmdIndex, caxis → clim, ...)

New Unsafe fixes (only with --fix --unsafe-fixes): STREMP's negated form (~isempty(strfind(s,p)) → contains(s,p)), FNAN with a logical operator behind it (if n == NaN | n > 3 → if isnan(n) | n > 3), and MCFIL (renames the classdef and the constructor to the file name, so a method that was never the constructor becomes one). IJCL now rewrites j to 1i (as MATLAB's fix does; 1j before), and AND2/OR2 replace exactly the reported operator, as MATLAB's fix does.

Custom checks: disallow_* instead of max_* ​

The old CUSTOM_CHECKS engine mapped MATLAB's disallow IDs (DAFBR, …) to invented numeric thresholds (max_branches, max_return_points, …). The DAF* checks are now what MATLAB means: a boolean flag that reports every use of the construct. As in MATLAB, all DAF* checks are off by default; SYSBANG is on (when the category is enabled at all).

[lint.rules.CUSTOM_CHECKS]beforenow
max_function_inputs, max_function_outputs, max_function_lines, max_line_length, max_nesting_depth, max_cyclomatic_complexitythreshold checksunchanged
max_strict_cyclomatic_complexityscript complexityrenamed max_script_cyclomatic_complexity (the old name still works, but is reported as a typo)
max_avg_cyclomatic_complexityanonymous complexityrenamed max_anonymous_cyclomatic_complexity (same)
max_branches, max_return_points, max_nested_functions, max_anonymous_functions, max_local_variables, max_local_constants, max_called_functions, max_semicolons_per_line, max_tree_children, max_persistent_variables, max_conditions, max_input_args_used, max_output_args_usednumeric limits misusing DAF* IDsremoved, replaced by disallow_bang, disallow_try_catch, disallow_persistent, disallow_continue, disallow_break, disallow_return, disallow_script, disallow_nested_functions, disallow_command_syntax, disallow_anonymous_functions, disallow_char_vectors, disallow_cellstr, disallow_varargin, disallow_varargout

A config that still sets a removed max_* key gets a warning listing the valid parameters (or fails with --strict-config).

NO4LP is now the parenthesised for check ​

The old NO4LP checked the indentation of loop and conditional bodies and took an indent_size parameter (while quoting MATLAB's unrelated message). NO4LP now means what MATLAB means: parentheses are not needed in a for statement (for (i = 1:n) → for i = 1:n, auto-fixed). The formatting engine takes no parameters; indent_size is gone. Indentation is no longer linted.

Checks that changed meaning ​

These IDs are still emitted, but they now report what MATLAB reports. The old uses were invented:

IDbeforenow
PSETpartial assignment in an if (invented)a persistent variable is used but never assigned
VUNUSassigned in all branches but unused after (invented)an operator expression or bare variable whose value is discarded (x{1};)
ASGSLassignment inside a condition (invented)self-assignment x = x; (assignment to variable might be unnecessary)
MSNUstruct field set but never read (a heuristic that misused the ID)a %#ok<ID> directive suppressed a message that was not generated (performance and unused engines)
MSNEstruct field does not exist (same misuse)a %#ok<...> element that is not a known check ID
DAF*numeric thresholdsdisallow flags (above)
NOSEMI, NO4LPsee abovesee above

PSIZE keeps its meaning (prod(size(x)) → numel(x)); severities and message texts across all checks were aligned with MathWorks' documentation index.

Removed check IDs ​

These were emitted before and no longer exist:

IDWhy removed
BDCFG, CFERR, BDOPT, CFIGMATLAB emits them only for checkcode -config on its own configuration files, which malt does not read. The whole CONFIG_ISSUES_ENGINE was dropped; the configuration-issues category is now empty but the [lint.categories] key is still accepted
PRTCALofficial formatting check, but MATLAB never fired it in any probe (built-in calls, local functions, methods, scripts) or fixture
VTPOD (removed, then back)removed because MATLAB reported FVSYN where malt reported VTPOD; emitted again for a class written before the size (a double (1,1)), which MATLAB reports as VTPOD
DEEPS, MBIG, TEXTLofficial incomplete-analysis limits that MATLAB in practice never reports (files of 1 to 16 MB, 5,000,000-character lines, deep nesting); deleted
EOFMIno evidence in MATLAB's output
TNMLPnot reproducible (it concerns loops over many functions)
EMS2Na Coder check checkcode never emits (probed with MATLAB Coder installed)

Declared but never emitted anymore (MATLAB reports none of them; the complete table with probe evidence is Official IDs malt does not emit): the code-gated FVUBD, FVONV, CLSUNK, SHVAI, SHVAU, LNGNM, BADOT, SYNEND, READSZK, FVATF, CTOINE, MWKCL, VANUS and NOEFF, plus the compatibility entries that need a variable of the class (pattern = "object", 183 of them) and the entries MATLAB was silent on in every probe form (pattern = "unverified": 13 compatibility and 24 suggested-improvement entries).

New IDs appeared on the other side: NOPAR and SEPEXC (syntax), BDSCA1, ISEQ, SUBSASGN, XPORD (good practices), DUPNAMEARG, SPBRK (language specification), SZCLN (compatibility), 29 new compatibility data entries (comm/dsp interleavers, PDSCHCONFIG, WSDLCLIENT, …; eight DLAB*/DNUMLABS entries moved to the suggested-improvements table), and MALT_TOO_DEEP and MALT_TOO_BIG. These two IDs are malt's own: safety limits on pathologically nested or very large input rather than MATLAB checks (see Resource limits). A full diff of the check inventory is easiest to see in the Rules Reference, which is generated from the rule sources.

Files over the resource limits are skipped ​

malt now protects the machine from pathological input, and the limits are on by default: a file over 5 MiB (max_file_size) is not read and gets a MALT_TOO_BIG error at line 1 (exit code 1); code nested more than 10,000 brackets (max_nesting) or 1,000 syntax-tree levels (max_tree_depth) gets MALT_TOO_DEEP; and max_threads (default: the number of cores) is now a total for the whole process, where before the file workers and the checks of one large file each used all the cores. Both IDs are malt's own, not MATLAB messages. If a project has files that large, either exclude them or raise the limit under [lint.limits]; read the warning in Resource limits first. The browser build (malt-wasm) defaults to 2 MiB and 200 levels.

The default now mirrors MATLAB's factory configuration ​

Under the mathworks preset (still the default when no .malt.toml exists) three things changed:

  1. Checks MATLAB never reports by default are off: ERTAG, WNTAG, CTCH, BDLOG2, LOGSUM, and every other entry of the off-list, each verified by probing. Only --preset all (or [lint] preset = "all") turns this part of the list back on, but a per-rule key does not. The compatibility part is finer-grained: an FC* gate comes back with [lint.rules] FCDQS = "error" (or the forward-compatibility category), and the low-reliability entries come back with the behavior-changes category.
  2. The 897 low-reliability compatibility entries and the seven forward compatibility gates (FCLEN, FCCPV, FCDQS, FCFAV, FCHBL, FCLFS, FCNVA) are off, as is IDISVARHIGH. They are also on with the behavior-changes category.
  3. Suggested improvements are on (MATLAB reports them by default; before they were an opt-in engine). The compatibility engine also matches more MATLAB shapes now: handle references (@psd), bare dotted names and the bare identifier of a multi-output assignment ([h, a] = legend;).

The presets themselves are unchanged by name (mathworks (default), recommended, all), and recommended still disables the same categories. To get the old broad behaviour back, run with --preset all (a superset of the old default: it also enables the naming, custom-check, Coder, Compiler, System Object and Unsupported engines). Expect different findings even then: where the old engines guessed, the new ones reproduce MATLAB.

New CLI features ​

FeatureEffect
--level <error|warning|info>show only that severity and above; hidden findings do not count and do not set the exit code
--color <auto|always|never>terminal colours, honouring NO_COLOR, CLICOLOR, FORCE_COLOR; auto by default
-v, -vvstderr progress: linted files (-v), per-file time and finding count (-vv); stdout unchanged
--strict-configexit 2 on any config problem instead of warning
--index / --no-indexthe optional path index (below)
MATLAB config discoverywithout a .malt.toml, malt now picks up resources/codeAnalyzerConfiguration.json in the working directory, and --config <file>.json reads one directly; [lint] matlab_config layers a .malt.toml over it
[index] in .malt.tomlenabled and paths for the path index: with it on, MCEB also reports events in a class whose superclasses are all value classes on the path (MATLAB refuses to load such a class). Off by default, so the output stays file-local

Files are now linted in parallel when not fixing (output order is the command-line order), and the Rust toolchain is pinned to 1.100.0 (rust-toolchain.toml), so contributors need rustup.

Config validation ​

.malt.toml rule keys and parameter names are now checked; each problem is one warning on stderr and the run continues:

text
warning: .malt.toml: unknown rule ID 'NOSMI' in [lint.rules] (did you mean 'NOSEMI'?)
warning: .malt.toml: unknown parameter 'max_variable_nam_length' for rule 'GOOD_PRACTICES_ENGINE' (did you mean 'max_variable_name_length'?)

Dotted IDs must be quoted: [lint.rules."naming.class.casing"] (an unquoted [lint.rules.naming.class.casing] is reported). --strict-config turns every warning into exit code 2. Use it in CI, so a typo cannot silently disable a rule. The removed max_* keys and ignore_functions are reported by the same mechanism.

Checklist ​

If your .malt.toml had… do this:

You hadDo
[lint.rules.NOSEMI] ignore_functions = [...]delete it; NOSEMI is now the extra-semicolon check. To tolerate missing semicolons, turn the real checks off: [lint.rules] NOPTS = "off" (scripts) and NOPRT = "off" (functions)
NOSEMI = "off" (to silence missing-semicolon noise)turn off NOPTS/NOPRT instead; keep NOSEMI on (it now finds a different thing)
[lint.rules.CUSTOM_CHECKS] with max_branches, max_return_points, max_local_variables, …replace with the disallow_* flags (they report every use, not a count); drop the rest
max_strict_cyclomatic_complexity / max_avg_cyclomatic_complexityrename to max_script_cyclomatic_complexity / max_anonymous_cyclomatic_complexity (the old names still work but warn)
[lint.rules.FORMATTING_ENGINE] indent_size = N or [lint.rules.NO4LP] indent_size = Ndelete it; malt no longer lints indentation
[lint.categories] configuration-issues = "..."nothing: the key is still accepted; the category has no checks
[lint.categories] suggested-improvements = "off" and you want the old silencekeep it; otherwise delete it, since the hints are on by default now
a [lint.rules] entry that turned an off-list check back on (e.g. ERTAG = "warn")re-check: engine off-list checks (ERTAG, WNTAG, CTCH, …) now need preset = "all". A rule key alone does not turn them on. FC* gates keep their per-rule switch, and the low-reliability entries come back with the behavior-changes category
a [lint.categories] entry re-enabling a preset-off category (e.g. custom-checks = "warn")nothing: explicit category entries still win over the preset
CI treating malt --fix as exit-0re-check: exit is 1 when findings remain, and unsafe rewrites need --fix --unsafe-fixes
CI that must not regress on typosadd --strict-config

And two new options worth adopting anywhere: --level warning in editors or gates that only care about real problems, and -v in scripts that want progress without changing the machine-readable stdout.

Copyright © 2026 Mark Shui Hu