Connected to SonarCloud or SonarQube (and which version):
And a thorough description of the problem / question:
SonarLint: ‘senderTeam’ is dereferenced.
SonarLint: A “NullPointerException” could be thrown; “senderTeam” is nullable here.
‘senderTeam’ cannot be null, as I am already checking its nullity with ‘warningKey’. If it is null, ‘warningKey’ is set, leading to the return statement before any operations on ‘senderTeam’ are executed.
Welcome to the community and thanks for this report!
The way I read this code, if game.getMode() == GameMode.SOLO then that’s the branch in the if-tree that gets taken, and you’ll never check senderTeam’s nullability.
I tried reproducing the problem, but it seems the issue is not raising.
Can you please provide me with a minimal reproducer so I can investigate where is the problem?