Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonar code detection problem repair #4360

Open
binbinCheng opened this issue Mar 13, 2023 · 1 comment
Open

Sonar code detection problem repair #4360

binbinCheng opened this issue Mar 13, 2023 · 1 comment

Comments

@binbinCheng
Copy link
Contributor

binbinCheng commented Mar 13, 2023

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
Copy link

😊 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
👉 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant