mlint - (Not recommended) Check MATLAB code files for possible problems - MATLAB (original) (raw)

(Not recommended) Check MATLAB code files for possible problems

Syntax

Description

mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d)) displays messages about 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 themlint messages is subject to some change between versions.

If filename specifies multiple files, MATLAB® displays information for each file.

mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-config=settings.txt') overrides the default active settings file with the settings that enable or suppress messages as indicated in the specified settings.txt file.

Note

When using this syntax, you must specify the full path to thesettings.txt file specified with the-config option.

For information about creating a settings.txt file, seeSave 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([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-config=factory') ignores all settings files and uses the factory default preference settings.

inform=mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-struct') returns the information in a structure array whose length is the number of messages found. The structure has these fields.

If you specify multiple filenames as input, inform contains a cell array of structures.

msg=mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-string') returns the information as the character vector 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([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d)) additionally returns filepaths, the absolute paths to the filenames, in the same order as in filename.

inform=mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-id') returns the message ID, where ID is a character vector of the formABC.... When returned to a structure, the output also has theid field, which is the ID associated with the message.

inform=mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-fullpath') assumes that the input filenames are absolute paths so that mlint does not try to locate them.

inform=mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-notok') checks all lines in filename, even those lines that end with themlint suppression directive, %#ok.

mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-cyc') 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.

mlint([filename](#mw%5Faf23c241-d737-4d10-aad3-536c101d6b6d),'-codegen') enables code generation messages for display in the Command Window.

Input Arguments

collapse all

filename — Name of file

string array | character vector | cell array of character vectors

Name of file, specified as a string array, character vector, or cell array of character vectors.

Tips

Extended Capabilities

Thread-Based Environment

Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.

Version History

Introduced before R2006a