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

Enable spotbugs and fix high priority bugs #38

Merged
merged 21 commits into from Jul 13, 2022

Conversation

kaijchen
Copy link
Contributor

@kaijchen kaijchen commented Jul 8, 2022

What changes were proposed in this pull request?

  1. Enable (previously experimental) spotbugs check in CI.
  2. Set spotbugs to only check high priority bugs.
    Because currently there are too many medium (default) priority bugs,
    and many of them are difficult to fix.
  3. Fix bugs reported by spotbugs.

Why are the changes needed?

To improve code quality.

Does this PR introduce any user-facing change?

One notable change is we are comparing content instead of reference of the array in ShufflePartitionedBlock#equals(), see: a994cff. We can revert it if it's not desired.

Another is toString() methods will call Arrays.toString() instead of printing array reference as string now.

How was this patch tested?

  1. mvn test-compile spotbugs:check -Pspark3
  2. mvn test-compile spotbugs:check -Pspark2
  3. mvn test-compile spotbugs:check -Pmr

Also by CI: https://github.com/kaijchen/incubator-uniffle/actions/runs/2634089750

@codecov-commenter
Copy link

codecov-commenter commented Jul 8, 2022

Codecov Report

Merging #38 (4288a2f) into master (0f6a896) will decrease coverage by 0.09%.
The diff coverage is 77.50%.

@@             Coverage Diff              @@
##             master      #38      +/-   ##
============================================
- Coverage     54.96%   54.86%   -0.10%     
+ Complexity     1094     1092       -2     
============================================
  Files           146      146              
  Lines          7778     7775       -3     
  Branches        749      749              
============================================
- Hits           4275     4266       -9     
- Misses         3267     3272       +5     
- Partials        236      237       +1     
Impacted Files Coverage Δ
.../java/org/apache/uniffle/common/BufferSegment.java 96.15% <0.00%> (-3.85%) ⬇️
...apache/uniffle/common/ShufflePartitionedBlock.java 35.29% <0.00%> (-1.07%) ⬇️
.../apache/uniffle/common/ShufflePartitionedData.java 0.00% <0.00%> (ø)
...org/apache/uniffle/common/config/ConfigOption.java 60.86% <0.00%> (-2.77%) ⬇️
...java/org/apache/uniffle/common/config/RssConf.java 28.96% <0.00%> (ø)
...niffle/storage/common/FileBasedShuffleSegment.java 51.51% <ø> (-1.43%) ⬇️
.../org/apache/uniffle/common/config/ConfigUtils.java 22.36% <60.00%> (ø)
.../java/org/apache/hadoop/mapreduce/RssMRConfig.java 87.50% <100.00%> (-4.17%) ⬇️
.../org/apache/uniffle/common/config/RssBaseConf.java 91.80% <100.00%> (ø)
...rg/apache/uniffle/coordinator/CoordinatorConf.java 96.15% <100.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f6a896...4288a2f. Read the comment docs.

@frankliee
Copy link
Contributor

frankliee commented Jul 13, 2022

It is better to decouple '3. Fix bugs reported by spotbugs' in another PRs to make this PR more independent.

@kaijchen
Copy link
Contributor Author

It is better to decouple '3. Fix bugs reported by spotbugs' in another PRs to make this PR more independent.

If we only include 1 and 2, the CI will fail.
If we only include 3, how do you know these bugs will be reported by spotbugs (and there is nothing more)?

@jerryshao jerryshao requested a review from frankliee July 13, 2022 07:37
@frankliee
Copy link
Contributor

frankliee commented Jul 13, 2022

It is better to decouple '3. Fix bugs reported by spotbugs' in another PRs to make this PR more independent.

If we only include 1 and 2, the CI will fail. If we only include 3, how do you know these bugs will be reported by spotbugs (and there is nothing more)?

It is possible to make this checker with optional rules to avoid break CI? If some changes are not what we really wanted.
This checker is powered by AI, and will not be always right.

@kaijchen
Copy link
Contributor Author

kaijchen commented Jul 13, 2022

It is possible to make this checker with optional rules to avoid break CI? If some changes are not what we really wanted.

Yes, it is possible to add suppressions (by annotation) and exclusions (by config).

This checker is powered by AI, and will not be always right.

It's not powered by AI, it's just static code analysis by pattern matching.

@@ -820,6 +820,7 @@
</dependency>
</dependencies>
<configuration>
<threshold>high</threshold>
Copy link
Contributor

Choose a reason for hiding this comment

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

What about other threshold?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will report too many errors, and some of them you might not want to fix.

For example, the default threshold is medium, see "Summary of failures" in
https://github.com/apache/incubator-uniffle/runs/7299882996?check_suite_focus=true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is a need, we can change it step by step, instead of trying to fix all of them in one huge PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think high is OK, LGTM.

@frankliee frankliee merged commit aa02ee6 into apache:master Jul 13, 2022
@kaijchen
Copy link
Contributor Author

Thanks @jerqi and @frankliee for the review.

@kaijchen kaijchen deleted the spotbugs branch July 13, 2022 09:20
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

4 participants