Creating Custom Rules with Scaffolding

Apr 07, 2013

Rules scaffolding is a quick way to create custom rules. If you want to create your custom rules and build them along with the OCLint building pipeline, scaffolding is the tool for the job.

For instance, to generate a rule, you could enter command similar to this in your terminal:

./scaffoldRule.py NoSwitchStatement -c controversial -p 2 -t ASTMatcher

The scaffold script will create a C** file, and store it in controversial folder under oclint-rules/rules. It will add the folder and new rule source file to the build process if necessary. The rule will inherit AbstractASTMatcherRule, populate name and priority according to the input.

You can tell the category, rule type, name, and priority to the scaffold script, or you can leave them with default settings.

Read on rule scaffolding document for details.