mlintrpt

Run checkcode for file or folder, reporting results in browser

Syntax

mlintrpt
mlintrpt('filename','file')
mlintrpt('dirname','dir')
mlintrpt('filename','file','settings.txt')
mlintrpt('dirname','dir','settings.txt')

Description

mlintrpt scans all files with an .m file extension in the current folder for Code Analyzer messages and reports the results in a MATLAB® Web browser.

mlintrpt('filename','file') scans filename for Code Analyzer messages and reports results. You can omit 'file' in this form of the syntax because it is the default.

mlintrpt('dirname','dir') scans the specified folder. Here, dirname can be in the current folder or can be a full path.

mlintrpt('filename','file','settings.txt') applies the Code Analyzer preference settings to enable or suppress messages as indicated in the specified settings.txt file.

mlintrpt('dirname','dir','settings.txt') applies the settings indicated in the specified settings.txt file.

    Note:   If you specify a settings.txt file, you must specify the full path to the file.

Examples

lengthofline.m is an example file with code that can be improved. It is found in matlabroot/matlab/help/techdoc/matlab_env/examples.

Run Report for All Files in a Folder

Run

mlintrpt(fullfile(matlabroot,'help','techdoc','matlab_env','examples'),'dir')

and MATLAB displays a report of potential problems and improvements for all files with an .m file extension in the examples folder.

For details about these messages and how to improve the code, see Changing Code Based on Code Analyzer Messages.

Run Report Using Code Analyzer Preference Settings

You can save preference settings to a text file by clicking the Preferences button in the Environment section on the Home tab and selecting Code Analyzer in the left pane. To save a preferences file, select Save as under the drop-down list. To apply those settings when you run mlintrpt, use the file option and supply the full path to the settings file name as shown in this example:

mlintrpt('lengthofline.m', 'file', ...
'C:\WINNT\Profiles\me\Application Data\MathWorks\MATLAB\R2012b\mymlint.txt')

Alternatively, use fullfile if the settings file is stored in the preferences folder:

 mlintrpt('lengthofline.m', 'file', fullfile(prefdir,'mymlint.txt'))

Assuming that in that example mymlint.txt file, the setting for Terminate statement with semicolon to suppress output has been disabled, the results of mlintrpt for lengthofline do not show that message for line 49.

When mlintrpt cannot locate the settings file, the first message in the report is

0: Unable to open or read the configuration file 'mymlint.txt'--using default settings.

See Also

Was this topic helpful?