sonarqube: removed some smells.

biggest change is that the HashSet and HashMap in LobbyConnection is now a Set and Map instead.
This commit is contained in:
Richard Reiber 2021-08-09 23:19:30 +02:00
parent d54d2004dd
commit 97a2cbb74e
5 changed files with 11 additions and 16 deletions

View File

@ -92,7 +92,6 @@ public class Server {
* It has to be executed <b>BEFORE ANY LOGGING OPERATIONS</b> .
*/
private static void setLogLevel(int logLevel) {
// System.out.println("setting log level to " + logLevel);
Map<String, String> map = new HashMap<>();
Configuration.replace(map);

View File

@ -1,13 +1,9 @@
package uulm.teamname.marvelous.server.lobby;
import uulm.teamname.marvelous.server.Server;
import uulm.teamname.marvelous.server.lobbymanager.Participant;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
/**
* A timer meant to time the entire Lifetime of the lobby, and if it is higher than the maximum permitted value,

View File

@ -28,19 +28,19 @@ public class TurnTimeoutTimer {
/**
* This method checks if the participant is not a spectator. Otherwise it won't start a timer.
*
* @param Participant the timer is for
* @param participant the timer is for
*/
public void startTurnTimer(Participant Participant) {
if (Participant.type == ParticipantType.Spectator) {
public void startTurnTimer(Participant participant) {
if (participant.type == ParticipantType.Spectator) {
throw new IllegalStateException("Spectators don't have TurnTime");
}
clear();
Logger.debug("Starting turn timer for participant '{}' with role {}",
Participant.id.getName(), Participant.type);
participant.id.getName(), participant.type);
current = timer.schedule(() -> {
callback.accept(Participant);
return Participant;
callback.accept(participant);
return participant;
},
maxRoundTime,
TimeUnit.SECONDS);

View File

@ -29,9 +29,9 @@ public class LobbyConnection implements Runnable {
private Participant player1;
private Participant player2;
private final HashSet<Participant> spectators = new HashSet<>(10);
private final HashMap<SUID, List<Integer>> selection = new HashMap<>(2);
public final HashMap<ParticipantType, CharacterProperties[]> options = new HashMap<>(2);
private final Set<Participant> spectators = new HashSet<>(10);
private final Map<SUID, List<Integer>> selection = new HashMap<>(2);
public final Map<ParticipantType, CharacterProperties[]> options = new HashMap<>(2);
private final BlockingQueue<Tuple<Participant, Request[]>> requestQueue = new LinkedBlockingQueue<>();
@ -117,7 +117,7 @@ public class LobbyConnection implements Runnable {
return player2;
}
public HashSet<Participant> getSpectators() {
public Set<Participant> getSpectators() {
return spectators;
}

View File

@ -43,7 +43,7 @@ class UserManagerTest {
@Test
void userIsConnectedTest() {
assertThat(manager.getUserCount()).isEqualTo(0);
assertThat(manager.getUserCount()).isZero();
assertThat(manager.containsConnection(socket1)).isFalse();
manager.connectUser(socket1);
assertThat(manager.getUserCount()).isEqualTo(1);