How to implement a Checkstyle Regexp rule in SonarQube

女生的网名这么多〃 提交于 2019-12-13 15:21:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!