MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

(^7) Review the message associated with each message ID to understand why it is
suppressed in the code or disabled in Preferences.
Understand the Limitations of Code Analysis
Code analysis is a valuable tool, but there are some limitations:



  • Sometimes, it fails to produce Code Analyzer messages where you expect them.


By design, code analysis attempts to minimize the number of incorrect messages it
returns, even if this behavior allows some issues to go undetected.


  • Sometimes, it produces messages that do not apply to your situation.


When provided with message, click the Detail button for additional information, which
can help you to make this determination. Error messages are almost always problems.
However, many warnings are suggestions to look at something in the code that is
unusual and therefore suspect, but might be correct in your case.

Suppress a warning message if you are certain that the message does not apply to
your situation. If your reason for suppressing a message is subtle or obscure, include a
comment giving the rationale. That way, those who read your code are aware of the
situation.

For details, see “Adjust Code Analyzer Message Indicators and Messages” on page 24-
11.

These sections describe code analysis limitations regarding the following:


  • “Distinguish Function Names from Variable Names” on page 24-16

  • “Distinguish Structures from Handle Objects” on page 24-17

  • “Distinguish Built-In Functions from Overloaded Functions” on page 24-18

  • “Determine the Size or Shape of Variables” on page 24-18

  • “Analyze Class Definitions with Superclasses” on page 24-18

  • “Analyze Class Methods” on page 24-18


Distinguish Function Names from Variable Names

Code analysis cannot always distinguish function names from variable names. For the
following code, if the Code Analyzer message is enabled, code analysis returns the

24 Coding and Productivity Tips

Free download pdf