Login
comments rule
Login

The rule to check if the selected file contains a comment with the selected pattern or a legal header. In the second option, it looks for word copyright in the first 5 lines of the file. The rule works differently than other rules, because it doesn't use AST representation of the checked code but operates directly on the file which contains the code.

The syntax in a configuration file is:

[ruleType] ?not? comments [checkType] [patternOrFileName]

Disabling the rule

It is possible to disable the rule for a selected part of the checked code by using pragma ruleOff: "comments" in the element from which the rule should be disabled or in code before it. For example, if the rule should be disabled for procedure proc main(), the full declaration of it should be:

proc main () {.ruleOff: "comments".}

To enable the rule again, the pragma ruleOn: "comments" 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 const a = 1, the full declaration should be:

const a {.ruleOn: "comments".} = 1

Examples

  1. Check if there is a comment which starts with FIXME word:

    check comments pattern ^FIXME

  2. Add a legal header from file legal.txt:

    fix comments legal legal.txt