SonarQube custom rule

  • What language are you writing rules for? Java

  • What have you tried, and what’s your challenge / stumbling block : Rule is working fine. But need to know something. If it’s possible or not.

    I came across some requirement from my team, where I need to switch the severity based on the number of lines in the method. If the number of lines is less than or equal to 10 then the severity should be info and if the lines count exceeds 10 then the severity should be major. But I think that it’s impossible but want to know is there any way to do it within a single rule.

    Thanks in advance


It’s not possible, the only way to do it is by having 2 different rules, one for each situation.

Also note that in SonarQube 10.2 the old rule severity was completely removed and replaced by something else: SQ 10.2 turn off rule severity is a breaking change - #11 by Chris


Thank you so much @felipebz .

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.