Skip to content

id-length

Enforce minimum and maximum lengths for identifiers

INFO

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

Rule details

This rule checks that the identifiers meet a minimum and/or maximum length. It will catch:

  • setting declarations
  • command declarations
  • constant declarations
  • structure declarations
  • structure member declarations
  • function declarations
  • function arguments declarations
  • variables declarations
  • labels declarations

Only declarations are checked. This prevents errors from being raised by code outside your control, such as using a constant from a library.

Settings

  • minimum the minimum length of identifiers. Default 2.
  • maximum the maximum length of identifiers. Default 60.
  • exceptions a list of identifiers that are not checked by the rule. Default [].

Example of incorrect code for this rule:

maniascript
/*
{
  "minimum" = 2,
  "maximum" = 10,
  "exceptions" = ["I", "TooLongButIgnored"]
}
*/
#Setting TooLongSetting 1
#Command TooLongCommand (Boolean)
#Const TooLongConstant 2
#Struct TooLongStruct {
  Integer TooLongStructMember;
}

Void TooLongFunction() {}
Void Function(Integer TooLongFunctionArg) {}

***TooLongLabel***
***
TooLongVariable = 1;
***

main() {
  declare Integer TooLongButIgnored;
  declare Integer[] TooLongVariable;
  +++TooLongLabel+++
  for (I, 0, 10) {}
  for (J, 0, 10) {}
}

Example of correct code for this rule:

maniascript
/*
{
  "minimum" = 2,
  "maximum" = 10,
  "exceptions" = ["I", "TooLongButIgnored"]
}
*/
#Setting Setting 1
#Command Command (Boolean)
#Const Constant 2
#Struct Struct {
  Integer Member;
}

Void Function() {}
Void Function(Integer Arg) {}

main() {
  declare Integer[] Variable;
  +++Label+++
  for (I, 0, 10) {}
  for (Count, 0, 10) {}
}

Resources