init-declaration
Require or forbid initialization in variable declarations
INFO
☑️ The predefined configuration "mslint:recommended" enables this rule.
Rule details
This rule enforces how variables must be initialized when they are declared.
Settings
targetselect how variables must be initialized when they are declared. DefaultAlwaysTrait. Can be :Always- all variables must be initialized when they are declared.AlwaysTrait- only traits (declare for) must be initialized when they are declared.Never- no variables must be initialized when they are declared.
Example of incorrect code for this rule:
maniascript
// { "target" = "Always" }
declare Integer A;
declare Integer B = 1;
declare Integer C for This;
declare Integer D for This = 1;
// { "target" = "AlwaysTrait" }
declare Integer A;
declare Integer B = 1;
declare Integer C for This;
declare Integer D for This = 1;
//{ "target" = "Never" }
declare Integer A;
declare Integer B = 1;
declare Integer C for This;
declare Integer D for This = 1;Example of correct code for this rule:
maniascript
// { "target" = "Always" }
declare Integer A = 1;
declare Integer B = 1;
declare Integer C for This = 1;
declare Integer D for This = 1;
// { "target" = "AlwaysTrait" }
declare Integer A;
declare Integer B = 1;
declare Integer C for This = 1;
declare Integer D for This = 1;
// { "target" = "Never" }
declare Integer A;
declare Integer B;
declare Integer C for This;
declare Integer D for This;