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等条件判断复杂度
··参考https://blog.csdn.net/ly969434341/article/details/97933936

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
··三元式运算不应该嵌套

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值