gjd6640 / sonar-text-plugin

A free and open-source plugin for SonarSource's Sonarqube product that lets you create rules to flag issues in text files.
Apache License 2.0
23 stars 4 forks source link

Allow for negation of the simple single-line rule #2

Open gjd6640 opened 8 years ago

gjd6640 commented 8 years ago

Sometimes you want to flag cases where a file is missing a certain pattern.

For example, a config file for a tool that sends alerts may need to specify the email address that notifications should go to. If the developer forgets to fill that field in the tool will do nothing; If they really want it to do nothing they should remove it. Sample file:

toolConfigBlah: do stuff this way
# notificationTarget: <todo: provide an email address here and uncomment this line before the first release of this software>

Rule would say: If "(?m)^notificationTarget: [regexEmailPattern]" doesn't exist in files named "theTool.config" raise an issue.

Note that the "Required String not Present" rule type allows you to do this already BUT it requires you to define a trigger string that must be present before an issue can be raised.