apache / linkis

Apache Linkis builds a computation middleware layer to facilitate connection, governance and orchestration between the upper applications and the underlying data engines.
https://linkis.apache.org/
Apache License 2.0
3.3k stars 1.16k forks source link

Sonar code detection problem repair #4360

Open binbinCheng opened 1 year ago

binbinCheng commented 1 year ago

Sonar code scanning, problem repair

example

1.Cast one of the operands of this multiplication operation to a "double".

企业微信截图_16786992744757 solve: Multiply two long types, the return parameter should be long type(两个long类型相乘,返回参数应为long类型)

2.Remove this conditional structure or edit its code blocks so that they're not all the same.

企业微信截图_16786993147906 solve: The code executed in if else is the same, meaningless code should be removed(if else中执行的代码是一样的,应该去掉无意义的代码)

3.This class overrides "equals()" and should therefore also override "hashCode()".

企业微信截图_16786993418774 solve: rewrite hashCode()(重写hashCode())

5.A "NullPointerException" could be thrown; "res" is nullable here.

企业微信截图_1678699380841

solve: Remove meaningless code and perform non-null check before execution(去除无意义代码且执行前应先做非空校验)

6.Correct one of the identical sub-expressions on both sides of operator "&&"

企业微信截图_16786994155850

Repeat condition, remove repeat condition(条件重复,去除重复条件)

7.Remove this dangerous instance of double-checked locking.(删除这个危险的双重检查锁定实例。)

企业微信截图_16788446534948

8.Use another way to initialize this instance.(使用另一种方式来初始化这个实例。)

企业微信截图_16788450596968

github-actions[bot] commented 1 year ago

:blush: Welcome to the Apache Linkis community!!

We are glad that you are contributing by opening this issue.

Please make sure to include all the relevant context. We will be here shortly.

If you are interested in contributing to our website project, please let us know! You can check out our contributing guide on :point_right: How to Participate in Project Contribution.

Community

WeChat Assistant WeChat Public Account

Mailing Lists

Name Description Subscribe Unsubscribe Archive
dev@linkis.apache.org community activity information subscribe unsubscribe archive