checkArgumentsBlockUsed

Verifies whether arguments blocks are used appropriately. This check can be configured to either require or forbid the use of input and/or output arguments blocks.

The arguments block, introduced in MATLAB R2019b, provides a powerful mechanism for validating input and output arguments. In addition to validation, it supports automatic type casting and reshaping. Compared to functions such as inputParser, narginchk, nargin, and varargin, it offers improved readability and better performance.

Functions without input arguments, or with only unnamed (~) input arguments, are excluded from checking for input arguments blocks. Likewise, functions without any output arguments are excluded from checking for output arguments blocks.

Configurable parameters

  • CheckInputOutput (list): Specifies which arguments blocks are checked. Possible values are Input and Output.

  • RequireProhibit (select): Determines whether the use of arguments blocks is mandatory or disallowed.

  • OnlyPublicFunctions (boolean): When set to true (default), the check is limited to public, visible functions and methods. With this option enabled, the following are excluded:

    • Functions located in a private folder.
    • Methods with restricted access.
    • Hidden methods.
    • Getter and setter methods.

    If a method is defined in a separate file and its class information cannot be retrieved (typically due to errors in the classdef file or during property initialization), it is still checked and reported as a regular function.

  • IgnoreSingleInputOrdinaryMethods (boolean): When set to true (default), ordinary (non-static) methods with a single input argument (one or more objects) are ignored. Since arguments blocks are usually unnecessary for such methods, this option helps reduce superfluous warnings.

  • CheckLocal (boolean): Set to true (default false) to include local functions in the check.

  • RequireSize (boolean): Set to true (default false) to require argument size specifications.

  • RequireClass (boolean): Set to true (default false) to require argument class specifications.

  • RequireValidators (boolean): Set to true (default false) to require argument validators.

Exemption tag: %@ok<CARBU>