I’m totally newbie in sonarqube.
I’m trying to write a custom rule to find where there are more than 3 “if-else” in the code.
Then mark it as a place where the programmer can apply the strategy design pattern.
Can someone give me a way?
I really want to learn how to use the SonarQube semantic API.
Thanks you!!
To build the rule you are talking about, I would look in the examples at the NoIfStatementRule that tests if there are if statements in Junit4 code.
If you want to dive deeper in the code, the CognitiveComplexityVisitor counts different elements in the code and takes the level of nesting into account.