Skip to content

max-depth

Prevent nested code blocks to exceed a maximum depth

INFO

☑️ The predefined configuration "mslint:recommended" enables this rule.

Rule details

This rule limits the depth of nested blocks to reduce code complexity.

Settings

  • maximum the maximum depth of nested blocks. Default 8.

Example of incorrect code for this rule:

maniascript
// { "maximum" = 4 }
Void Function () {
  if (True) {
    // depth 1
    if (True) {
      // depth 2
      if (True) {
        // depth 3
        if (True) {
          // depth 4
          if (True) {
            // depth 5
            if (True) {
              // depth 6
            }
          }
        }
      }
    }
  }
}

Example of correct code for this rule:

maniascript
// { "maximum" = 4 }
Void Function () {
  if (True) {
    // depth 1
    if (True) {
      // depth 2
      if (True) {
        // depth 3
        if (True) {
          // depth 4
          declare Integer A = 1;
        }
      }
    }
  }
}

Resources