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

pmd :: CollapsibleIfStatement #1061

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sambish5
Copy link
Collaborator

resolves the pmd warnings, as well as the sonar complaints about these collapsible if statements

@sambish5 sambish5 added the tech-debt Low-impact cleanup and upkeep label Feb 10, 2025
}
if ((rollingHash % (this.blockSize * 2)) == ((this.blockSize * 2) - 1) && this.fuzzLen2 < (SPAMSUM_LENGTH / 2 - 1)) {
this.fuzzHash2[this.fuzzLen2++] = b64EncodeLowBits(this.sumHash2);
this.sumHash2 = HASH_INIT;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some of these I wonder if there is benefit to making them a method rather than jamming them in the above line. Here we have code that looks very similar to the above (line 185) where perhaps refactoring this would benefit more than just this line/warning.

@@ -154,11 +154,9 @@ private long getIntervalInMillis() {
private boolean shouldRoll(long start) {
// verify both time and progress are set
// if we're below max we'll check the interval
if (period > 0 && max > 0 && progress.get() < max) {
if (period > 0 && max > 0 && progress.get() < max && ((start - lastRun + 100) < getIntervalInMillis())) {
// we fired a progress run or delayed start due to starvation. add 100 for clock skew
Copy link
Collaborator

Choose a reason for hiding this comment

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

To make this read correctly with the comments, perhaps a method for the second if statement would be nicer?

@jpdahlke jpdahlke added this to the v8.23.0 milestone Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-debt Low-impact cleanup and upkeep
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants