不合理代码"/>
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使用,调整不合理代码
发布评论