SonarQube Trigger a rule check from another rule inside plugin

Hi @niteesh22, generally speaking, each rule should be independent of the others; one reason for this is that there is no guarantee about the order in which rules are executed. So, you should not create a dependency between rules, any way you can implement a more specialized rule that reuses the logic from another rule.

In your case, I would separate the 2 rules. You can see the second rule as a special case of the first rule, which covers the subset of use cases determined by your conditions.

Have a look at the BrainMethodCheck, which first visits all the files in the module, collects the state information required and finally in the endOfAnalysis reports the issues in case some conditions are met.

I hope this will help you achieve the desired behavior.

1 Like