id: 1809 name: Remove this call from a constructor to the overridable "setFormat" method. type: CODE SMELL severity: CRITICAL Comment: Calling an overridable method from a constructor could result in failures or
3、Call "remove()" on "requestContainer". 说明:防止内存泄露溢出,ThreadLocal字段【requestContainer】应该至少调用一次remove()方法。 // 解决方案:定义删除方法 public void removeRequest() { requestContainer.remove(); } 4、Use try-with-resources or close this "FileInputStream" in a "finally" claus...
1.Replace the type specification in this constructor call with the diamond operator ("<>"). Java 7引入了菱形运算符(<>)来减少泛型代码的冗长。 例如,您现在可以使用<>简化构造函数声明,而不必在其声明及其构造函数中声明List的类型,编译器将推断该类型。如下: 2.Add a default case to this switch swa...
Cast one of the operands of this integer division to a "double" Remove this throw statement from this finally block. Remove this return statement from this finally block A "NullPointerException" could be thrown; "pkList" is nullable here. Use try-with-resources or close this "ResultSet" in...
Boxing/unboxing to parse a primitive ... 使用parse方法来代替valueOf方法 Null passed for non-null parameter of ... 将一个可能为空的参数传到了一个方法中,但在该方法中,该参数不可为空。修改这个方法,在使用变量前进行非空判断,则这个参数就成为了可为空参数 Remove this "Integer" constructor 不要使...
Define a constant instead of duplicating this literal "muluList" 6 times.某个字符串出现了4次或以上,需要定义⼀个常量来代替 A method/constructor shouldnt explicitly throw java.lang.Exception不能直接抛出Exception,需要精确到具体的异常,且最多抛出4个,超过请try catch Define and throw a dedicated ...
目录Bugs Use an "instanceof" comparison instead. Cast one of the operands of this integer division to a "double" Remove this throw statement from this finally block. Remove this ret... 查看原文 .Net插件编程模型:MEF和MAF ;/": result =operands[0] /operands[1]; break; default:thrownew Ex...
2.Add a default case to this switch swatch 中没有default,也没有break;虽然上面的代码不要break也不会有什么问题。但是万一哪天变了,不是return 就很容易出错了吧。 3.Remove this empty statement. 两个分号,代码中有很多地方有这种情况感觉,删掉多余的。
Empower development teams with a self-hosted code quality and security solution that deeply integrates into your enterprise environment; enabling you to deploy clean code consistently and reliably. Try SonarQube Server SonarQube Cloud Clean Code in your cloud workflow ...
30、Move the array designator from the variable to the type. 问题分析: 数组指示符应始终位于类型上,以提高代码可读性。否则,开发人员必须同时查看类型和变量名,以了解变量是否为数组。 解决: 将[]从变量名后面放到变量名前面。 31、Replace the type specification in this constructor call with the diamond ...