Skip to content

Commit

Permalink
Fixing sonarqube recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaremagico committed Sep 22, 2024
1 parent 6468ff6 commit 44c50ee
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import com.softwaremagico.kt.core.score.CompetitorRanking;
import com.softwaremagico.kt.core.score.ScoreOfCompetitor;
import com.softwaremagico.kt.core.tournaments.BubbleSortTournamentHandler;
import com.softwaremagico.kt.core.tournaments.SenbatsuTournamentHandler;
import com.softwaremagico.kt.persistence.entities.Club;
import com.softwaremagico.kt.persistence.entities.Group;
import com.softwaremagico.kt.persistence.entities.Participant;
Expand Down Expand Up @@ -122,6 +123,8 @@ public class RankingController {

private final BubbleSortTournamentHandler bubbleSortTournamentHandler;

private final SenbatsuTournamentHandler senbatsuTournamentHandler;

public RankingController(GroupProvider groupProvider, GroupConverter groupConverter,
TournamentConverter tournamentConverter, FightConverter fightConverter,
TeamConverter teamConverter, DuelConverter duelConverter,
Expand All @@ -131,7 +134,7 @@ public RankingController(GroupProvider groupProvider, GroupConverter groupConver
ScoreOfTeamConverter scoreOfTeamConverter,
ClubProvider clubProvider, ParticipantProvider participantProvider, ClubConverter clubConverter,
RoleProvider roleProvider, TournamentProvider tournamentProvider,
BubbleSortTournamentHandler bubbleSortTournamentHandler) {
BubbleSortTournamentHandler bubbleSortTournamentHandler, SenbatsuTournamentHandler senbatsuTournamentHandler) {
this.groupProvider = groupProvider;
this.groupConverter = groupConverter;
this.tournamentConverter = tournamentConverter;
Expand All @@ -149,6 +152,7 @@ public RankingController(GroupProvider groupProvider, GroupConverter groupConver
this.roleProvider = roleProvider;
this.tournamentProvider = tournamentProvider;
this.bubbleSortTournamentHandler = bubbleSortTournamentHandler;
this.senbatsuTournamentHandler = senbatsuTournamentHandler;
}

private static Set<ParticipantDTO> getParticipants(List<TeamDTO> teams) {
Expand Down Expand Up @@ -181,9 +185,14 @@ public List<ScoreOfTeamDTO> getTeamsScoreRankingFromTournament(Integer tournamen
() -> new TournamentNotFoundException(this.getClass(), "No tournamnet exists with id '" + tournamentId + "'."));
final List<ScoreOfTeamDTO> ranking = scoreOfTeamConverter.convertAll(rankingProvider.getTeamsScoreRankingFromTournament(tournamentId)
.stream().map(ScoreOfTeamConverterRequest::new).toList());
//Bubble sort is different. The winner is only on the first group.
if (tournament.getType().equals(TournamentType.BUBBLE_SORT)) {
final List<Team> sortedTeams = bubbleSortTournamentHandler.getTeamsOrderedByRanks(tournament);
//Bubble sort and Senbatsu are different. The winner is only on the first group.
if (tournament.getType().equals(TournamentType.BUBBLE_SORT) || tournament.getType().equals(TournamentType.SENBATSU)) {
final List<Team> sortedTeams;
if (tournament.getType().equals(TournamentType.BUBBLE_SORT)) {
sortedTeams = bubbleSortTournamentHandler.getTeamsOrderedByRanks(tournament);
} else {
sortedTeams = senbatsuTournamentHandler.getFinalRanking(tournament);
}
Collections.reverse(sortedTeams);
final List<ScoreOfTeamDTO> scoreOfTeamDTOS = new ArrayList<>();
final AtomicInteger counter = new AtomicInteger(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public static void warning(Logger logger, String className, String messageTempla
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
}
}
final String templateWithClass = className + ": " + messageTemplate;
logger.warn(templateWithClass.replaceAll("[\n\r]", "_"), arguments);
final String templateWithClass = (className + ": " + messageTemplate).replaceAll("[\n\r]", "_");
logger.warn(templateWithClass, arguments);
}
}

Expand All @@ -79,7 +79,8 @@ public static void info(Logger logger, String messageTemplate, Object... argumen
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
}
}
logger.info(messageTemplate.replaceAll("[\n\r]", "_"), arguments);
messageTemplate = messageTemplate.replaceAll("[\n\r]", "_");
logger.info(messageTemplate, arguments);
}
}

Expand Down Expand Up @@ -111,7 +112,8 @@ public static void debug(Logger logger, String messageTemplate, Object... argume
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
}
}
logger.debug(messageTemplate.replaceAll("[\n\r]", "_"), arguments);
messageTemplate = messageTemplate.replaceAll("[\n\r]", "_");
logger.debug(messageTemplate, arguments);
}
}

Expand All @@ -132,6 +134,7 @@ public static void debug(Logger logger, String className, String messageTemplate
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
}
}
messageTemplate = messageTemplate.replaceAll("[\n\r]", "_");
logger.debug(String.format("%s: %s", className, messageTemplate), arguments); //NOSONAR
}
}
Expand All @@ -150,7 +153,8 @@ protected static void severe(Logger logger, String messageTemplate, Object... ar
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
}
}
logger.error(messageTemplate.replaceAll("[\n\r]", "_"), arguments);
messageTemplate = messageTemplate.replaceAll("[\n\r]", "_");
logger.error(messageTemplate, arguments);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
max-height: 400px;
}

.team-list > horizontal {
min-height: 5vh;
max-height: 20px;
}

.mat-raised-button {
width: 150px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<mat-divider [vertical]="true" *ngIf="(RbacActivity.READ_TEAMS_RANKINGS | rbac : this.rbacService.getActivities()) ||
(RbacActivity.READ_COMPETITORS_RANKINGS | rbac : this.rbacService.getActivities())"></mat-divider>
<button (click)="showTeamsClassification(areAllDuelsOver())" *ngIf="((tournament && tournament.teamSize && tournament.teamSize>1) || (tournament && tournament.type === kingOfTheMountainType)
|| (tournament && tournament.type === bubbleSortType))
|| (tournament && tournament.type === bubbleSortType) || (tournament && tournament.type === TournamentType.SENBATSU))
&& (RbacActivity.READ_TEAMS_RANKINGS | rbac : this.rbacService.getActivities())"
[disabled]="!groups[0] || !groups[0].fights || groups[0].fights.length == 0"
[matTooltipShowDelay]="500" color="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
max-height: 400px;
}

.team-list > horizontal {
min-height: 5vh;
max-height: 20px;
}

.mat-raised-button {
width: 150px;
}
Expand Down

0 comments on commit 44c50ee

Please sign in to comment.