简体   繁体   English

包名称应符合命名约定(squid:S00120)和下划线

[英]Package names should comply with a naming convention (squid:S00120) and underscore

SonarLint produces an error: SonarLint产生错误:

Package names should comply with a naming convention (squid:S00120) ... With the default regular expression ^[az]+(\\.[az][a-z0-9]*)*$.

However the JLS allows and even recommends using the underscore. 但是,JLS允许甚至建议使用下划线。 Clause 6.1. 第6.1条。 Declarations says, ia, 声明说,ia,

If the domain name contains a hyphen, or any other special character not allowed in an identifier (§3.8), convert it into an underscore. 如果域名包含连字符或标识符(第3.8节)中不允许的任何其他特殊字符,请将其转换为下划线。

Can I change the regular expression or must it be fixed in the product? 我可以更改正则表达式还是必须在产品中修复?

Consider using a SonarQube server. 考虑使用SonarQube服务器。 You can connect your SonarLint plugin to the server and manipulate the way SL performs SCA in your IDE. 您可以将SonarLint插件连接到服务器,并操纵SL在IDE中执行SCA的方式。

One of the nicer features of SQ is the ability to disable SCA rules and remove them from all future scan. SQ的一个更好的功能是能够禁用SCA规则并将其从以后的所有扫描中删除。 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. 使用此功能,您可以禁用包名称规则(我也觉得讨厌),a并没有使编辑视图混乱。

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. 另一种选择是创建一个新规则,该规则将对包名称强制执行新的正则表达式约定 - 例如,允许包名称为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 . 最后,如规定乔纳森·罗森到问题的评论,这乔纳森以下这个问题打开了包的名字问题SONARJAVA-2596已经固定,可以看出这里

Reference: 参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM