Sonar 全称 SonarQube,是一种静态代码检查工具,采用 B/S 架构,帮助检查代码缺陷,改善代码质量,提高开发速度,通过插件形式,可以支持 Java、C、C++、JavaScript 等二十几种编程语言的代码质量管理与检测。
大家都在Idea用sonar插件扫描自己的项目代码,以提高自己的代码质量。本文主要介绍自己在工作中用soanr工具检查JAVA代码时常见的问题及对应修改建议,对有些问题还做了修改分析。文中如有不妥的地方或者有更好的建议,欢迎留言讨论。
SonarLint: Merge this if statement with the enclosing one |
https://blog.csdn.net/libusi001/article/details/103717499 |
SonarLint: Replace "@RequestMapping(method = RequestMethod.GET)" with "@GetMapping" [+1 location] |
https://blog.csdn.net/libusi001/article/details/103804753 |
SonarLint: Format specifiers should be used instead of string concatenation. |
SonarLint: 'password' detected in this expression, review this potentially hard-coded credential. |
SonarLint: 'if' statement can be simplified. SonarLint: Replace this if-then-else statement by a single return statement. |
https://blog.csdn.net/libusi001/article/details/103808958 |
SonarLint: Use try-with-resources or close this "BufferedOutputStream" in a "finally" clause. |
https://blog.csdn.net/libusi001/article/details/103848922 |
SonarLint: Change this "try" to a try-with-resources. [+2 locations] |
Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed. [+12 locations] |
https://blog.csdn.net/libusi001/article/details/103893391 |
有用请点赞,养成良好习惯!
鼓励、疑问、交流请留言!