问题
SonarLint produces an error:
Package names should comply with a naming convention (squid:S00120) ... With the default regular expression ^[a-z]+(\.[a-z][a-z0-9]*)*$.
However the JLS allows and even recommends using the underscore. Clause 6.1. Declarations says, i.a.,
If the domain name contains a hyphen, or any other special character not allowed in an identifier (§3.8), convert it into an underscore.
Can I change the regular expression or must it be fixed in the product?
回答1:
Consider using a SonarQube server. You can connect your SonarLint plugin to the server and manipulate the way SL performs SCA in your IDE.
One of the nicer features of SQ is the ability to disable SCA rules and remove them from all future scan. Using this feature, you can disable the package name rule (which I also find annoying),a and not have it clutter up the editing view.
Another option is to create a new rule, which will enforce a new regular expression convention on the package names - for example, allowing package names to be Camel Case.
Finally, as stated by Jonathan Rosenne in a comment to the question, the package name issue SONARJAVA-2596 which Jonathan had opened following this question has been fixed, as can be seen here.
Reference:
- How to disable a rule in SonarQube
- Writing Custom Java Rules 101
来源:https://stackoverflow.com/questions/47858665/package-names-should-comply-with-a-naming-convention-squids00120-and-undersco