| MATLAB® | ![]() |
| On this page… |
|---|
Enable integrated M-Lint warning and error messages |
These preferences apply to the M-Lint code analyzer operating automatically in the Editor and the Embedded MATLAB™ Editor (if you have products which use that tool), as well as to the M-Lint Code Check Report, with a few exceptions that are noted. For more information about M-Lint, see M-Lint Code Analyzer.
Select this check box if you want the Editor to show M-Lint messages in the M-file. This preference does not apply to the M-Lint Code Check Report or the Embedded MATLAB Editor. With this preference selected, the Editor provides visual cues that alert you to potential errors and problems, as well as opportunities for improvement in your code. These visual cues take the form of underlines and a message indicator bar. From these cues, you can view a message for each line of an M-file that M-Lint indicates might be improved. For example, a common M-Lint message is that a variable is defined but never used in the M-file.
Restrict the M-Lint underlining notification via the associated drop-down list. The list is available only when Enable integrated M-Lint warning and error messages is selected. Options are
Underline warnings and errors
Underline errors only
No underlines
Errors appear underlined in red, while warnings are underlined in orange. For all of the underlining options, the Editor provides the marks for errors and warnings in the indicator bar.
You might choose a different option at different stages in your workflow. For example, when first coding, you might prefer no underlines because they would appear as you enter a statement and might be distracting. Later, you might choose to underline only errors to help you debug your file. Finally, when tweaking an existing M-file, you might want to underline warnings and errors because the file is in a state that you can fix any issues you introduce at the time.
Click Adjust autofix highlight color to open the Colors Preferences dialog box so that you can adjust the color that M-Lint uses to highlight errors and warnings that it can fix automatically. By default, this color is pale orange.
In the Color Preferences dialog box, in the Other colors group, use the M-Lint autofix highlight palette to select a color. For more information, see M-Lint Automatic Code Analyzer in the Editor.
Use M-Lint settings to show or hide specific messages or categories of messages when you use M-Lint. If you are new to using M-Lint or MATLAB®, use the default settings. However, once you are familiar with M-Lint and MATLAB, you might want to suppress the display of certain M-Lint messages. To suppress an M-Lint message on a particular line in an M-file, use the %#ok syntax—for details, see Ignore Only a Specific Instance, or the mlint function. To suppress messages in more than one file, it is more convenient to disable the M-Lint preference settings, as described here:
In Select messages to enable, select the check boxes for messages to enable, that is choose the messages you want M-Lint to show. Clear the check boxes for messages you want to disable, that is hide. Note that you cannot disable M-Lint error messages, such as syntax errors, and therefore they are not listed. For more information about specific messages, see Making Changes Based on M-Lint Messages.
Then click Apply or OK to cause the settings take effect. If you do not click Apply or OK and you then try to choose a different option from the Active settings drop-down list, MATLAB prompts you to save changes—see Saving Settings. Like all preferences, the settings are retained for you next MATLAB session.
Note that if you add %#ok in an M-file, it suppresses the M-Lint message display at that particular line, even when the preference is set to show that message.
If you are likely to use different settings at different times, or if you want to make these settings available to other users, click Save As. MATLAB prompts you to provide the name of the txt file in which the settings are saved. The default location for settings is the MATLAB preferences directory (the directory returned when you run prefdir), although you can choose a different directory when saving.
To use settings previously saved, select the settings txt file from the Active settings drop-down list. Choose from the recently-used settings files, which are shown, or select Browse to locate the settings file. Then click Apply or OK to make the settings take effect. You can also access saved settings from within the Editor using Tools > M-Lint, or the M-Lint message bar.
After selecting a settings file, you can modify the settings, but your changes automatically modify the txt file. If you want to retain the settings in the txt file, you need to create a copy of the settings file in which you can make changes. To do so, click Save As and save the file to a different name. Then make changes to the newly named file.
The Active settings indicator shows Default Settings when you are using the default settings rather than settings from a txt file. The term (modified) appears when you have made changes to default settings but have not saved the changes to a file. To undo any unsaved changes and return to the default settings, click Restore Defaults. If you think you will use the modified default settings in a future session, save the settings as described in Saving Settings.
When a txt file is selected, return to default settings by using the drop-down list to select Default Settings or Default Settings (modified).
By default, messages are grouped by Category, where a category is a group of messages, such as Aesthetics and Readability. Another way to group is by Enabled/Disabled, which lists all disabled messages, followed by all the enabled messages.
Select this check box to show the MATLAB® Compiler™ (deployment ) messages. With this check box selected, the actual Compiler messages that can display are those selected in the Select messages to enable. area of the M-Lint preferences panel, under the MATLAB Compiler (deployment) messages category, as described in Active settings.
You can also access this setting from Editor Tools > M-Lint menu. This setting allows you to easily switch between showing or hiding Compiler messages of interest to you when you work on a file to be deployed versus a file that will not be deployed. When you change the preference, it also changes the setting in the Editor. The converse is also true—when you change the setting from the Editor, it effectively changes this preference, however you will not see the changes reflected in the M-Lint Preferences if Preferences is open at the time you make the change. Whether or not you change the setting from the Editor or from M-Lint Preferences, it applies to the Editor and to the M-Lint Code Check Report.
The status of this setting is included in the M-Lint settings txt file, created via Saving Settings.
To use and specify the background color for code that M-Lint can automatically fix, use Colors Preferences—for more information, see Other Colors.
![]() | Preferences for the Editor/Debugger | Examples | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |