问题
In my team, we have switched from using Checkstyle and FindBugs to SonarQube, for many reasons, and particularly because of the dashboards, as they make it easier to have a global view of where we stand.
However, in the process, we have lost a few useful checks that I am trying to convert / reimplement with SonarQube. In particular, our Java code (legacy and newer) is plagued by a use of several logging platforms/libraries: slf4j+logback, Commons Logging, Java Util Logging, etc.
My use case for the Regexp in Checkstyle is to define a rule so that the only imports allowed for logging are based on slf4j.
SonarQube maintains a page that gives the implementation status of Checkstyle rules and I see Regexp in the list of rejected rules.
Is there a means to implement the Regexp rule or is it just a use case that will not be? I haven't been able to find an explanation of the rejection of each of the rejected rules, to see if there were recommendations.
回答1:
Given your usecase I think you can make use of Disallowed class rule template : https://jira.sonarsource.com/browse/RSPEC-3688 to track where the improper loggers are used.
来源:https://stackoverflow.com/questions/50949936/how-to-implement-a-checkstyle-regexp-rule-in-sonarqube