3. Predefined Rules

The description of the rules currently implemented in gnatcheck is given in this chapter. The rule identifier is used as a key for LKQL rule configuration objects (see LKQL rule file), and as first parameter of gnatcheck’s +R or -R switches.

Be aware that most of these rules apply to specialized coding requirements developed by individual users and may well not make sense in other environments. In particular, there are many rules that conflict with one another. Proper usage of gnatcheck involves selecting the rules you wish to apply by looking at your independently developed coding standards and finding the corresponding gnatcheck rules.

Unless documentation is specifying some, rules don’t have any parameters.

If not otherwise specified, a rule does not do any check for the results of generic instantiations.

GNATcheck’s predefined rules’ parameters may have the following types:

bool

The parameter represents a boolean value, toggling a rule behavior. In a LKQL rule file you have to associate a boolean value to the parameter name:

val rules = @{
   My_Rule: {Bool_Param: true}
}

To specify a boolean parameter through a +R option, you just have to provide the parameter’s name to set it to true:

+RMy_Rule:Bool_Param  -- 'Bool_Param' value is set to true
int

The parameter is an integer value. In a LKQL rule options file, you have to associate an integer value to the parameter name:

val rules = @{
   My_Rule: {N: 5} # If the rule param is named 'N'
}

To specify it with a +R option, you can write its value right after the rule name:

+RMy_Rule:5  -- 'My_Rule' integer param is set to 5
string

The parameter value is a string, sometimes with formatting constraints. In a LKQL rule options file, you just have to provide a string value:

val rules = @{
   My_Rule: {Str: "i_am_a_string"} # If the rule param is named 'Str'
}

You can specify it through the +R option also by passing a string right after the rule name:

+RMy_Rule:i_am_a_string  -- 'My_Rule' string param is set to "i_am_a_string"
list[string]

The parameter value is a list of string. In a LKQL rule options file, you can use the LKQL list type to specify the parameter value:

val rules = @{
   My_Rule: {Lst: ["One", "Two", "Three"]} # If the rule param is named 'Lst'
}

Through the +R option, you can specify it as a collection of string parameters separated by commas:

+RMy_Rule:One,Two,Three  -- 'My_Rule' string list param is set to ["One", "Two", "Three"]