Skip to content
github-actions[bot] edited this page Nov 22, 2024 · 3 revisions

The nesting depth of methods/procedures/if-statements/loop-statements should not exceed the defined maximum nesting depth threshold.

Deeply nested code may perform poorly, is difficult to understand and can be difficult to test thoroughly.

Non-compliant Code Example

_if a _isnt _unset
_then
  _for x _over a.fast_elements()
  _loop
    _if x _isnt _unset
    _then
      _for child _over x.fast_elements()
      _loop
        _return child
      _endloop
    _endif
  _endloop
_else
  _return b
_endif

Compliant Code Example

_if a _is _unset _then _return b _endif

_for x _over a.fast_elements()
_loop
  _if x _is _unset
  _then
    _continue
  _endif

  _for child _over x.fast_elements()
  _loop
    _return child
  _endloop
_endloop

Options

Option Default value Description
nesting-depth.max-nesting-depth 3 Maximum nesting depth
nesting-depth.count-early-return-as-nesting-depth true Count early return as nesting depth

Note

This page is generated. Any changes made to this page through the wiki will be lost in the future.