Sonarlint使用,调整不合理代码

编程入门 行业动态 更新时间:2024-10-13 20:14:44

Sonarlint使用,调整<a href=https://www.elefans.com/category/jswz/34/1748872.html style=不合理代码"/>

Sonarlint使用,调整不合理代码

1.“static” base class members should not be accessed via derived types
··父类的静态成员不应该使用子类访问。
··Critial code smell
····PageHelper.offsetPage(0, 3, false);
改为PageMethod.offsetPage(0, 3, false);
····JSONObject summaryMap = JSONObject.parseObject(projectSummary, JSONObject.class);
改为JSONObject summaryMap = JSON.parseObject(projectSummary, JSONObject.class);

2.String literals should not be duplicated

3.Composed “@RequestMapping” variants should be preferred
···@RequestMapping(value = “/test/wdws”, method = RequestMethod.GET, produces = “application/json”)
改为@GetMapping(value = “/test/wdws” , produces = “application/json”)

4.Cognitive Complexity of methods should not be too high
··降低方法内if else, Switch等条件判断复杂度
··参考

5.Lambdas containing only one statement should not nest this statement in a block
··只包含一条语句的Lambdas(匿名函数)不应该将此语句嵌套在块中(无需用{})

6.Collection.isEmpty() should be used to test for emptiness
··用isEmpty()可读性比Collection.size()>0更高

7.Public constants and fields initialized at declaration should be “static final” rather than merely “final”
··make this final field static too

8.Multiple variables should not be declared on the same line
··不要在同一行定义多个变量

9.Constant names should comply with a naming convention
··常量名称应该符合命名约定

10.Assignments should not be made from within sub-expressions
··不应该在子表达式中进行赋值

11.Ternary operators should not be nested
··三元式运算不应该嵌套

更多推荐

Sonarlint使用,调整不合理代码

本文发布于:2024-03-10 17:07:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1728543.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不合理   代码   Sonarlint

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!