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

[SpotBugs] Set threshold to middle with exceptions #517

Merged
merged 7 commits into from
Jan 30, 2023

Conversation

kaijchen
Copy link
Contributor

@kaijchen kaijchen commented Jan 29, 2023

What changes were proposed in this pull request?

  1. Enable middle priority checks in spotbugs.
  2. Fix some violations.
  3. Exclude other violations to make CI pass.

Why are the changes needed?

Enforce stronger code quality check.
See violations fixed in this PR for example.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Run mvn test-compile spotbugs:check manually.

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2023

Codecov Report

Merging #517 (e53fd86) into master (6076226) will decrease coverage by 0.03%.
The diff coverage is 33.33%.

@@             Coverage Diff              @@
##             master     #517      +/-   ##
============================================
- Coverage     59.79%   59.76%   -0.03%     
+ Complexity     1770     1768       -2     
============================================
  Files           205      205              
  Lines         11531    11531              
  Branches       1033     1033              
============================================
- Hits           6895     6892       -3     
- Misses         4231     4233       +2     
- Partials        405      406       +1     
Impacted Files Coverage Δ
...ge/handler/impl/PooledHdfsShuffleWriteHandler.java 0.00% <0.00%> (ø)
...rg/apache/uniffle/server/buffer/ShuffleBuffer.java 93.38% <100.00%> (ø)
...rg/apache/uniffle/storage/common/LocalStorage.java 48.36% <0.00%> (-1.97%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -91,7 +92,7 @@ public synchronized ShuffleDataFlushEvent toFlushEvent(
* So we should create a reference copy to avoid this.
*/
inFlushedQueueBlocks = new LinkedList<>(spBlocks);
spBlocks.sort((o1, o2) -> new Long(o1.getTaskAttemptId()).compareTo(o2.getTaskAttemptId()));
Copy link
Contributor Author

@kaijchen kaijchen Jan 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Long() is a bad practice, Long.valueOf() should be used.

@@ -55,7 +55,7 @@ public PooledHdfsShuffleWriteHandler(
// todo: support init lazily
try {
for (int i = 0; i < maxConcurrency; i++) {
queue.offer(
Copy link
Contributor Author

@kaijchen kaijchen Jan 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's expected to success here, we should always check the result of BlockingQueue#offer().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code seems a bit strange... Could we add some comment macro to disable this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is possible to add @SuppressFBWarnings annotation.
But I think the original code looks strange, should we do some refactor?

@kaijchen kaijchen changed the title [CI] Enable spotbugs middle with exceptions [SpotBugs] Set threshold to middle with exceptions Jan 30, 2023
spotbugs-exclude.xml Show resolved Hide resolved
@@ -55,7 +55,7 @@ public PooledHdfsShuffleWriteHandler(
// todo: support init lazily
try {
for (int i = 0; i < maxConcurrency; i++) {
queue.offer(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code seems a bit strange... Could we add some comment macro to disable this check?

@advancedxy
Copy link
Contributor

Thanks @kaijchen, I'm merging this.

@advancedxy advancedxy merged commit b80972c into apache:master Jan 30, 2023
@kaijchen kaijchen deleted the spotbugs branch January 30, 2023 07:16
@kaijchen
Copy link
Contributor Author

Ref #532

kaijchen added a commit that referenced this pull request Feb 2, 2023
### What changes were proposed in this pull request?

Remove SC_START_IN_CTOR from `spotbugs-exclude.xml`.
It was excluded in #517 by mistake.

### Why are the changes needed?

#462 

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

CI.
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

Successfully merging this pull request may close these issues.

None yet

3 participants