java-design-patterns icon indicating copy to clipboard operation
java-design-patterns copied to clipboard

SonarQube reports bugs

Open iluwatar opened this issue 8 years ago • 7 comments

There are 2 critical level bugs found by SonarQube.

https://sonarcloud.io/project/issues?id=com.iluwatar%3Ajava-design-patterns&resolved=false&severities=BLOCKER%2CCRITICAL&types=BUG

iluwatar avatar Nov 04 '18 18:11 iluwatar

@iluwatar I will take a look at this.

IAmPramod avatar Nov 13 '18 10:11 IAmPramod

Ok @IAmPramod

iluwatar avatar Nov 18 '18 19:11 iluwatar

Hi The sonarQube says as a possible solution is to use: SecureRandom.getInstanceStrong() Instead using new Random().

But it throws a NoSuchAlgorithmException and I don't know what to put in the catch block. I would leave it blank because I'm setting idx variable to 0 and if the exception is thrown the method will return the first Player.

Here a snippet of my solution: (Please, take a look)

private static PlayerDetails getRandomPlayerDetails() {
    int idx = 0;
    try {
      idx = SecureRandom.getInstanceStrong().nextInt(PLAYERS.size());
    } catch (NoSuchAlgorithmException e) {}
    return PLAYERS.get(idx);
  }

Thank you

diegocmsantos avatar Nov 20 '18 16:11 diegocmsantos

@IAmPramod : Are you working on this?

navishsharma avatar May 15 '19 17:05 navishsharma

Ping @IAmPramod

iluwatar avatar May 19 '19 08:05 iluwatar

I am willing to take a look at this issue if @IAmPramod doesn't answer. I'm on the hunt for a "good first issue" :)

matheusrc avatar Jun 02 '19 13:06 matheusrc

Go ahead @matheusrc the issue is yours

iluwatar avatar Jun 03 '19 04:06 iluwatar