checkWarningUsed

Checks if warnings are used. Do not throw warnings, if necessary throw errors instead. Using errors instead of warnings improves the robustness of the code. Warnings cannot reliably be caught and handled and therefore often accomplish little. The check ignores calling warning for disabling, enabling, or querying a warning. This means that using for example warning('off', 'matlab:my:identifier'); is not reported by this check.

Limitations

This check also reports cases where a warning state is set using a variable. Consider the following example:

warningState = 'off';
warning(warningState, 'matlab:my:identifier');

The statements do not issue a warning when run, but this check reports the second statement.

This check also reports calls to warning when you have shadowed the MATLAB-installed function with a local one..

Exemption tag: %@ok<WARNU>