Here is a bunch of things to do you may consider once your rule is “up and running”.
Rule priority may, of course, change a lot depending on the context of the project. However, you can use thefollowing guidelines to assert the legitimate priority of your rule:
For instance, let’s take the ruleDoNotCallGarbageCollectionExplicitly(“Do not explicitly trigger a garbage collection.”). Calling GC isa bad idea, but it doesn’t break the application. So we skip priority one. However, as explicit call to gc may reallyhinder application performances, we settle for priority 2 (“Medium High”).
You should try to run the rule on a large code base, like the jdk source code for instance. This will help ensurethat the rule does not raise exceptions when dealing with unusual constructs.
If your rule is stateful, make sure that it is reinitialized correctly for each file.
When writing a new rule, using command line option--benchmarkon a few rules can give an indication on how the rule compares to others. To get the full pictureuse therulesets/internal/all-java.xml ruleset with--benchmark.
Rules which use theRuleChainto visit the AST are faster than rules which perform manual visitation of the AST.The difference is small for an individual Java rule, but when running 100s of rules, it is measurable.For XPath rules, the difference is extremely noticeable due to the overhead for AST navigation.Make sure your XPath rules using the RuleChain. If RuleChain can’t be used for your XPath rule, then this factis logged as a debug message.