Login
hasEntity rule
Login

The rule to check if the selected module has the selected entities, like procedures, constants, etc. with the selected names. The syntax in a configuration file is

[ruleType] ?not? hasentity [entityType] [entityName] ?parentEntity? ?childIndex?

To look only for global entities, add * to the end of the entityName parameter. Setting it to MyProc* will look only for global entities which full name is MyProc.

Note

hasEntity rule is considered as a low level rule. It requires a knowledge about Nim compiler, especially names of the Nim code nodes and the generated source code tree to use. It is recommended to use other rules instead of this one.

Disabling the rule

It is possible to disable the rule for a selected part of the checked code by using pragma ruleOff: "hasEntity" before the code's fragment which shouldn't be checked.

To enable the rule again, the pragma ruleOn: "hasEntity" should be added before the code which should be checked.

Examples

  1. Check if module has declared global procedure with name myProc:

    check hasEntity nkProcDef myProc*

  2. Search for all defined global constants:

    search hasEntity nkConstSection *

  3. Count the amount of global enumerations:

    count hasEntiry nkEnumTy *

  4. Check if there are no declarations of global range types:

    check not hasEntity nkRange *