Skip to content

1010: Fixed all of the blocking and critical Sonarcloud errors#1020

Merged
iluwatar merged 2 commits into
iluwatar:masterfrom
oconnelc:1010
Oct 19, 2019
Merged

1010: Fixed all of the blocking and critical Sonarcloud errors#1020
iluwatar merged 2 commits into
iluwatar:masterfrom
oconnelc:1010

Conversation

@oconnelc
Copy link
Copy Markdown
Contributor

Fixed all of the blocking and critical Sonarcloud errors

There were 12 blocking and critical errors in Sonarcloud. They are:

  • circuit-breaker/.../com/iluwatar/circuitbreaker/App.java: Add an end condition to this loop
  • commander/.../java/com/iluwatar/commander/Order.java: Save and re-use this "Random"
  • commander/.../java/com/iluwatar/commander/Retry.java: Save and re-use this "Random"
  • commander/.../java/com/iluwatar/commander/Service.java: Save and re-use this "Random"
  • hexagonal/.../iluwatar/hexagonal/sampledata/SampleData.java: Save and re-use this "Random"
  • leader-election/.../com/iluwatar/leaderelection/AbstractInstance.java: Add an end condition to this loop
  • master-worker-pattern/.../java/com/iluwatar/masterworker/ArrayUtilityMethods.java: Save and re-use this "Random"
  • priority-queue/.../com/iluwatar/priority/queue/Worker.java: Add an end condition to this loop
  • producer-consumer/.../com/iluwatar/producer/consumer/Producer.java: Save and re-use this "Random"
  • retry/.../main/java/com/iluwatar/retry/RetryExponentialBackoff.java: Save and re-use this "Random"
  • spatial-partition/.../com/iluwatar/spatialpartition/Bubble.java: Save and re-use this "Random"
  • typeobjectpattern/.../java/com/iluwatar/typeobject/CellPool.java: Save and re-use this "Random"

Since there were only two types of rules, the changes can be summarized as:

  1. Add an end condition to this loop: put a SuppressWarning annotation so SonarCloud will ignore

  2. Save and re-use this "Random": Make the random a constant in the file.

All of these files are causing SonarCloud to report the following error:

Loops should not be infinite

Since these instances all require an infinite loop that will never end,
these warnings should be disabled so that SonarCloud no longer reports
them as error.

The rule is: squid:S2189
According to SonarCloud rule: "Random" objects should be reused, randoms
should not be recreated. This commit has taken all of the Randoms and made
them constant variables in the files that are using them.
@iluwatar
Copy link
Copy Markdown
Owner

Looks good to me. Let's verify after the next scan that the blockers and criticals are gone.

@iluwatar iluwatar merged commit 7c5d5f6 into iluwatar:master Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants