sonar
代码质量管理
服务器sonar
有专业的管理页面,对git上的代码进行扫描,实现对项目的整体分析,sonar的问题标注点比较清晰
idea的sonar
以前安装过发现要使用到服务器地址,现在安装发现不需要服务器的sonar支持,可能是升级了吧,安装过程容易失败,网上也有对应的解决方案
sonar代码检查
方法复杂度问题
这个很有学习价值,看下面的官方解释
https://www.sonarsource.com/docs/CognitiveComplexity.pdf
比较的要求
Comparisons of dissimilar types will always return false. The comparison and all its dependent code can simply be removed. This includes:
- comparing an object with null
- comparing an object with an unrelated primitive (E.G. a string with an int)
- comparing unrelated classes
- comparing an unrelated class and interface
- comparing unrelated interface types
- comparing an array to a non-array
- comparing two arrays
数组比较工具
Arrays.equals(array1, array2)