mlint
(Not recommended) Check MATLAB code files for possible problems
mlint
is not recommended. Use checkcode
instead.
For information on using the graphical user interface to the Code Analyzer, see Check Code for Errors and Warnings Using the Code Analyzer.
Syntax
Description
mlint(
displays messages about filename
)filename
that report potential problems
and opportunities for code improvement. These messages are sometimes referred to as
Code Analyzer messages. The line number in a message is a hyperlink that you can
click to go directly to that line in the Editor. The exact text of the
mlint
messages is subject to some change between versions.
If filename
specifies multiple files, MATLAB® displays information for each file.
mlint(
overrides the default active settings file with the settings that enable or suppress
messages as indicated in the specified filename
,'-config=settings.txt')settings.txt
file.
Note
When using this syntax, you must specify the full path to the
settings.txt
file specified with the
-config
option.
For information about creating a settings.txt
file, see
Save and Reuse Code Analyzer Message Settings. If you specify an
invalid file, mlint
returns a message indicating that it cannot
open or read the file you specified. In that case, mlint
uses
the factory default settings.
mlint(
ignores all settings files and uses the factory default preference settings.filename
,'-config=factory')
inform=mlint(
returns the information in a structure array whose length is the number of messages
found. The structure has these fields.filename
,'-struct')
message
— Message describing the potential code issue identified during code analysis.line
— Vector of file line numbers to which the message refers.column
— Two-column array of file columns (column extents) to which the message applies. The first column of the array specifies the column in the Editor where the message begins. The second column of the array specifies the column in the Editor where the message ends. There is one row in the two-column array for each occurrence of a message.
If you specify multiple filenames as input, inform
contains a
cell array of structures.
msg=mlint(
returns the information as the character vector filename
,'-string')msg
. If you
specify multiple filenames as input, msg
contains information for
each file, separated by 10 equal sign characters (=
), a space,
the filename, a space, and 10 equal sign characters.
If you omit the -struct
or -string
argument and you specify an output argument, the default
behavior is -struct
. If you omit the argument and
there are no output arguments, the default behavior is to display the information to
the command line.
[inform,filepaths]=mlint(
additionally returns filename
)filepaths
, the absolute paths to the
filenames, in the same order as in filename
.
inform=mlint(
returns the message ID, where ID is a character vector of the form
filename
,'-id')ABC...
. When returned to a structure, the output also has the
id
field, which is the ID associated with the message.
inform=mlint(
assumes that the input filenames are absolute paths so that filename
,'-fullpath')mlint
does not try to locate them.
inform=mlint(
checks all lines in filename
,'-notok')filename
, even those lines that end with the
mlint
suppression directive, %#ok
.
mlint(
displays the
McCabe complexity (also referred to as cyclomatic complexity)
of each function in the file. Higher McCabe complexity values indicate higher
complexity, and evidence suggests that programs with higher complexity values are
more likely to contain errors. Frequently, you can lower the complexity of a
function by dividing it into smaller, simpler functions. In general, lower
complexity values indicate programs that are easier to understand and modify. You
may want to split up programs that have a complexity rating over 10.filename
,'-cyc')
mlint(
enables code
generation messages for display in the Command Window.filename
,'-codegen')
Input Arguments
Tips
For information on the suppression directive,
%#ok
, and suppressing messages from within your program, see Adjust Code Analyzer Message Indicators and Messages.
Extended Capabilities
Version History
Introduced before R2006a