Main Content

Code Analyzer Preferences

Code Analyzer Preferences

You can change how Code Analyzer messages appear in the Editor and Live Editor. With a few exceptions, these preferences apply to messages in the Editor, Live Editor, MATLAB® Function Block Editor (if your products use that tool), and Code Analyzer Report.

On the Home tab, in the Environment section, click Preferences. Select Code Analyzer, and then adjust preference options as described in the table below.

OptionUsage
Enabled Integrated Warning and Error Messages

Specify whether you want to display Code Analyzer message indicators, such as the underlining of code and the message indicator bar, for documents open in the Editor.

For more information, see Check Code for Errors and Warnings Using the Code Analyzer.

Underlining

Specify the type of coding issues that you want to have underlined.

Regardless of the underlining menu option you choose, the Editor marks errors and warnings in the message indicator bar.

Autofix

Provides a link to a preference panel that enables you to adjust the color highlighting errors and warnings that MATLAB can autofix. You trigger autofix by clicking the Fix button in a Code Analyzer message.

Active Settings

Select the set of message settings to use. Click the down arrow to select or browse to a previously saved settings file.

Actions button

Click to open a menu that enables you to select:

  • Save as — Saves the current Code Analyzer message settings to a file.

    The default location for settings is the MATLAB preferences folder (the folder returned when you run prefdir).

  • Restore Defaults — Restores default Code Analyzer message settings.

Search field

Searches the list of Code Analyzer messages that display below the search field. For details, see Search for Messages in the Code Analyzer Preferences.

Code Analyzer message settings

Select or clear messages to enable or suppress their appearance in your Editor documents.

To expand or collapse all categories in the list, right-click anywhere in the list and select Expand All or Collapse All.

To suppress a message on a line-by-line or file-by-file basis, see Adjust Code Analyzer Message Indicators and Messages.

Search for Messages in the Code Analyzer Preferences

You can search the list of Code Analyzer messages in the Code Analyzer preferences to display only those messages that are currently of interest to you. Use any combination of the methods that the following table presents.

Note

If you do not have the MATLAB Compiler™ installed, the Code Analyzer preferences pane does not display the MATLAB Compiler (deployment) messages category.

To See a List of Messages ...Perform this action...Example Scenario

Containing specified text in the:

  • Short message

  • Extended message

  • Message category

  • Message ID

In MATLAB Online™, the extended message is not included in the search.

Type the text in the search field.

You recall seeing a message containing some text that you want to review, but you cannot remember the exact message text.

For example, type com in the search field to display those messages that contain that text in the short message, extended message, or message ID.

Corresponding to a given message ID

Type msgid: followed by a space and the message ID in the search field.

You are reviewing the code that someone else wrote and you want to see the message that corresponds to a suppressed one using the %#ok<AGROW> directive.

Type msgid: agrow in the search field. Messages IDs containing AGROW display as links. Click each link for more information about the message.

Not all Code Analyzer messages have additional information. These messages do not appear as links.

That you can set using Code Analyzer preferences

Click the down arrow to the right of the search field, and then click Show All.

You want to see the complete list of messages after you have searched the messages for some text or a given search menu option.

Different from the default setting (of enabled or disabled)

Click the down arrow to the right of the search field, and then click Show Messages Modified from Default.

A gray dot precedes a message with a setting different from the default. For example:

A coworker gave you a settings file and you want to review each message that the coworker changed from its default setting.

In a given category

Click the down arrow to the right of the search field, click Show Messages in Category, and then click the category you want.

You want to review messages that describe coding practices that make it difficult for others to use your code.

Click the down arrow to the right of the search field, select Show Messages in Category, and then select Aesthetics and Readability.

Click the messages that appear as links for more information. Not all messages appear as links.

That are warnings

Click the down arrow to the right of the search field, and then select Show All Warnings. An exclamation point in a yellow triangle indicates a warning message.

You recall previous warnings that your code generated, but you cannot remember enough details to use the search field to find it. You want to skim all the warning messages to find a particular one of interest.

Are errors

Click the down arrow to the right of the search field, and then select Show All Errors. By default, an X in a red dot indicates an error message, .

You want to find a message elicited by a script you worked on previously. All you can recall is that it was an error and it involved parfor.

Click the down arrow to the right of the search field, and then select Show All Errors. Then, type a space and parfor in the search field.

The Code Analyzer preference pane displays only error messages that contain the word parfor.

Are disabled

Click the down arrow to the right of the search field, and then select Show Disabled Messages.

You want to see the messages that are disabled by default or you have previously disabled.

Example of Searching Messages

To display Code Analyzer error messages that contain the word variable and are disabled:

  1. Click the down arrow in the search field, and then select Show All Errors.

    The search field contains severity:error.

  2. At the end of the text severity:error, press the Space key, and then type variable.

  3. Click the down arrow in the search field and select Show Disabled Messages.

The search field now contains severity:error variable enabled:false. Only the messages that fulfill those requirements appear in the Preferences pane. To restore the list of all messages, click the clear search button .

The Show All Errors and Show Disabled Messages options are not available in MATLAB Online.

Related Topics