The rule to check do object's types' declarations in the code contains or not some expressions. Checked things:
- Do the object's type's declaration contains public fields.
The syntax in a configuration file is:
[ruleType] ?not? objects [checkType]
- ruleType is the type of rule which will be executed. Proper values are:
check, search, count and fix. For more information about the types of
rules, please refer to the program's documentation. Check type will raise
an error if there is an object's type's declaration which violates the check.
Search type will list all declarations which violates the check or raise an
error if nothing found. Count type will simply list the amount of the
declarations which violates the check. Fix type will add or remove public mark
*
from fields' of the object's type's declaration. - optional word not means negation for the rule. Adding word not will change to inform only about objects' types' declarations which have only private fields.
- objects is the name of the rule. It is case-insensitive, thus it can be set as objects, objects or oBjEcTs.
- checkType is the type of checks to perform on the objects' declarations. Proper values are: publicfields, all, standardtypes. Setting it to publicfieds will check existence of objects declarations which contains public fields. Setting it to standardtypes will check existence of objects' declarations which contains fields with string or int type. Setting it to all will perform all checks.
Disabling the rule
It is possible to disable the rule for a selected part of the checked code
by using pragma ruleOff: "objects" in the element from which the rule
should be disabled or in code before it. For example, if the rule should
be disabled for type myObject
, the full declaration of it should
be:
{.ruleOff: "objects".}
type myObject = object
field: string
To enable the rule again, the pragma ruleOn: "objects" should be added in
the element which should be checked or in code before it. For example, if
the rule should be re-enabled for myRecord
declaration, the full declaration
should be:
{.ruleOn: "objects".}
type myRecord = object
field: string
Examples
Check if all objects' types' declarations contains public fields and standard types:
check objects all
Made all object's types' fields private::
fix not objects publicfields