Rule Guidelines, or the last touches to a rule
Table of ContentsHere is a bunch of things to do you may consider once your rule is âup and runningâ.
How to define rules priorityRule priority may, of course, change a lot depending on the context of the project. However, you can use the following guidelines to assert the legitimate priority of your rule:
For instance, letâs take the rule DoNotCallGarbageCollectionExplicitly
(âDo not explicitly trigger a garbage collection.â). Calling GC is a bad idea, but it doesnât break the application. So we skip priority one. However, as explicit call to gc may really hinder 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 ensure that 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.
Performance issuesWhen writing a new rule, using command line option --benchmark
on a few rules can give an indication on how the rule compares to others. To get the full picture use the rulesets/internal/all-java.xml
ruleset with --benchmark
.
Rules which use the RuleChain to 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 fact is logged as a debug message.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4