Skip to content

Commit

Permalink
Fixing sonarqube issue
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaremagico committed May 12, 2024
1 parent a38406b commit 693b4d2
Show file tree
Hide file tree
Showing 39 changed files with 143 additions and 166 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {ClubListComponent} from "./views/club-list/club-list.component";
import {LoggedIn, LoggedInService} from './interceptors/logged-in.service';
import {LoggedIn} from './interceptors/logged-in.service';
import {LoginComponent} from './views/login/login.component';
import {AuthenticatedUserListComponent} from "./views/authenticated-user-list/authenticated-user-list.component";
import {PasswordsComponent} from "./views/passwords/passwords.component";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/charts/colors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class Colors {
public static defaultPalette: string[] = [
public static readonly defaultPalette: string[] = [
"#001239",
"#6f8bff",
"#8097b3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export class GaugeChartComponent extends CustomChartComponent {
this.chartOptions = {
colors: this.colors,
chart: this.getChart('radialBar', this.width, this.height, this.shadow, this.showToolbar),
series: this.data!.getValues(),
labels: this.data!.getLabels(),
series: this.data.getValues(),
labels: this.data.getLabels(),
fill: this.getFill(this.fill, this.opacity),
plotOptions: this.getPlotOptions(),
tooltip: this.getTooltip(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class FightStatisticsPanelComponent extends KendoComponent implements OnI

ngOnInit(): void {
this.statisticsChangedService.areStatisticsChanged.pipe(takeUntil(this.destroySubject)).subscribe(() => {
if (this.tournament && this.tournament.id) {
if (this.tournament?.id) {
this.statisticsServices.getFightStatistics(this.tournament.id, !this.teams, this.teams).subscribe((_fightStatistics) => {
if (_fightStatistics === undefined || _fightStatistics === null) {
_fightStatistics = new TournamentFightStatistics();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/fight/fight.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class FightComponent extends RbacBasedComponent implements OnInit {

ngOnInit(): void {
this.duelChangedService.isDuelUpdated.pipe(takeUntil(this.destroySubject)).subscribe(selectedDuel => {
if (selectedDuel && this.fight && this.fight.duels) {
if (selectedDuel && this.fight?.duels) {
this.selected = false;
this.selectedDuel = undefined;
for (let duel of this.fight.duels) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class TeamRankingComponent extends RbacBasedComponent implements OnInit {
if (this.tournament) {
if (this.tournament.type == TournamentType.CHAMPIONSHIP) {
if (this.group) {
const rankingRequest: Observable<ScoreOfTeam[]> = this.rankingService.getTeamsScoreRankingByGroup(this.group!.id!);
const rankingRequest: Observable<ScoreOfTeam[]> = this.rankingService.getTeamsScoreRankingByGroup(this.group.id!);
const winnersRequest: Observable<TournamentExtendedProperty> = this.tournamentExtendedPropertiesService.getByTournamentAndKey(this.tournament, TournamentExtraPropertyKey.NUMBER_OF_WINNERS);

forkJoin([rankingRequest, winnersRequest]).subscribe(([_scoresOfTeams, _numberOfWinners]): void => {
Expand Down Expand Up @@ -107,7 +107,7 @@ export class TeamRankingComponent extends RbacBasedComponent implements OnInit {
downloadPDF(): void {
if (this.tournament) {
if (this.tournament.type == TournamentType.CHAMPIONSHIP && this.group) {
this.rankingService.getTeamsScoreRankingByGroupAsPdf(this.group!.id!).subscribe((pdf: Blob): void => {
this.rankingService.getTeamsScoreRankingByGroupAsPdf(this.group.id!).subscribe((pdf: Blob): void => {
const blob: Blob = new Blob([pdf], {type: 'application/pdf'});
const downloadURL: string = window.URL.createObjectURL(blob);
const anchor: HTMLAnchorElement = document.createElement("a");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import {
Component,
ElementRef,
EventEmitter,
Input,
OnChanges,
OnDestroy,
OnInit,
Output,
SimpleChanges,
ViewChild
} from '@angular/core';
import {Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild} from '@angular/core';
import {Group} from "../../models/group";
import {CdkDragDrop, transferArrayItem} from "@angular/cdk/drag-drop";
import {Team} from "../../models/team";
Expand Down Expand Up @@ -102,7 +91,6 @@ export class TournamentBracketsEditorComponent implements OnInit, OnDestroy {
});
this.topicSubscription = this.rxStompService.watch(this.websocketsPrefix + '/groups').subscribe((message: Message): void => {
const messageContent: MessageContent = JSON.parse(message.body);
//if (messageContent.topic == "Group" && messageContent.actor !== localStorage.getItem("username")) {
if (messageContent.topic == "Group") {
this.updateData(false);
}
Expand All @@ -121,10 +109,10 @@ export class TournamentBracketsEditorComponent implements OnInit, OnDestroy {

updateData(showBusy: boolean): void {
this.systemOverloadService.isBusy.next(showBusy);
if (this.tournament && this.tournament.id) {
if (this.tournament?.id) {
const teamsRequest: Observable<Team[]> = this.teamService.getFromTournament(this.tournament);
const groupsRequest: Observable<Group[]> = this.groupService.getFromTournament(this.tournament.id!);
const relationsRequest: Observable<GroupLink[]> = this.groupLinkService.getFromTournament(this.tournament.id!);
const groupsRequest: Observable<Group[]> = this.groupService.getFromTournament(this.tournament.id);
const relationsRequest: Observable<GroupLink[]> = this.groupLinkService.getFromTournament(this.tournament.id);

forkJoin([teamsRequest, groupsRequest, relationsRequest]).subscribe(([_teams, _groups, _groupRelations]): void => {
if (_teams) {
Expand Down Expand Up @@ -163,10 +151,10 @@ export class TournamentBracketsEditorComponent implements OnInit, OnDestroy {
const relations: Map<number, { src: number, dest: number, winner: number }[]> = new Map();
if (groupRelations) {
for (const groupLink of groupRelations) {
if (!relations.get(groupLink.source!.level!)) {
relations.set(groupLink.source!.level!, []);
if (!relations.get(groupLink.source.level!)) {
relations.set(groupLink.source.level!, []);
}
relations.get(groupLink.source!.level!)?.push({
relations.get(groupLink.source.level!)?.push({
src: groupLink.source!.index!,
dest: groupLink.destination!.index!,
winner: groupLink.winner
Expand All @@ -184,7 +172,7 @@ export class TournamentBracketsEditorComponent implements OnInit, OnDestroy {
event.previousIndex,
event.currentIndex,
);
this.groupService.deleteTeamsFromTournament(this.tournament!.id!, this.teamListData.teams).subscribe();
this.groupService.deleteTeamsFromTournament(this.tournament.id!, this.teamListData.teams).subscribe();
this.teamListData.filteredTeams.sort((a: Team, b: Team) => a.name.localeCompare(b.name));
this.teamListData.teams.sort((a: Team, b: Team) => a.name.localeCompare(b.name));
}
Expand Down Expand Up @@ -227,7 +215,7 @@ export class TournamentBracketsEditorComponent implements OnInit, OnDestroy {
const groupsByLevel: Map<number, Group[]> = TournamentBracketsComponent.convert(this.groups);
const height: number = groupsByLevel.get(0)?.length! * BracketsMeasures.GROUP_SEPARATION + this.totalTeams * 100;
//const width = Math.max(groupsByLevel.size!, 3) * 500 + 100;
const width: number = (groupsByLevel.size! + 1) * (BracketsMeasures.GROUP_WIDTH + BracketsMeasures.LEVEL_SEPARATION + 100);
const width: number = (groupsByLevel.size + 1) * (BracketsMeasures.GROUP_WIDTH + BracketsMeasures.LEVEL_SEPARATION + 100);
const orientation: "p" | "portrait" | "l" | "landscape" = "landscape";
const imageUnit: "pt" | "px" | "in" | "mm" | "cm" | "ex" | "em" | "pc" = "px";
const widthMM: number = this.getMM(width);
Expand Down Expand Up @@ -305,7 +293,7 @@ export class TournamentBracketsEditorComponent implements OnInit, OnDestroy {
//Send final teams
let observables: Observable<any>[] = [];
for (const group of groups) {
observables.push(this.groupService.addTeamsToGroup(group!.id!, group.teams));
observables.push(this.groupService.addTeamsToGroup(group.id!, group.teams));
}
//Ensure all groups are updated.
forkJoin(observables)
Expand All @@ -332,7 +320,7 @@ export class TournamentBracketsEditorComponent implements OnInit, OnDestroy {
}

removeAllTeams(): void {
this.groupService.deleteAllTeamsFromTournament(this.tournament!.id!).subscribe((_groups: Group[]): void => {
this.groupService.deleteAllTeamsFromTournament(this.tournament.id!).subscribe((_groups: Group[]): void => {
this.groupsUpdatedService.areTeamListUpdated.next([]);
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Component, Input, OnInit} from '@angular/core';
import {CdkDrag, CdkDragDrop, CdkDropList, transferArrayItem} from "@angular/cdk/drag-drop";
import {Team} from "../../../../models/team";
import {Group} from "../../../../models/group";
import {TournamentBracketsComponent} from "../tournament-brackets.component";
import {GroupService} from "../../../../services/group.service";
import {GroupsUpdatedService} from "../groups-updated.service";
import {Tournament} from "../../../../models/tournament";
Expand Down Expand Up @@ -57,11 +56,11 @@ export class GroupContainerComponent implements OnInit {
}

dropTeam(event: CdkDragDrop<Team[], any>): void {
const team: Team = this.transferCard(event);
this.transferCard(event);
this.groupHigh = this.getGroupHigh(this.level, this.index);
this.groupService.setTeamsToGroup(this.groupsByLevel!.get(this.level)![this.index]!.id!, this.groupsByLevel.get(this.level)![this.index].teams)
this.groupService.setTeamsToGroup(this.groupsByLevel.get(this.level)![this.index]!.id!, this.groupsByLevel.get(this.level)![this.index].teams)
.subscribe((_group: Group): void => {
this.groupsByLevel!.get(this.level)![this.index] = _group;
this.groupsByLevel.get(this.level)![this.index] = _group;
})
}

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {Tournament} from "../../../../models/tournament";

@Component({
selector: 'app-shiaijo',
templateUrl: './shiaijo.component.html',
styleUrls: ['./shiaijo.component.scss']
templateUrl: './shiaijo.component.html'
})
export class ShiaijoComponent {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class TournamentBracketsComponent implements OnInit {
}

getGroupHigh(level: number, index: number): number {
if (this.groupsByLevel && this.groupsByLevel!.get(level) && this.groupsByLevel.get(level)![index]) {
if (this.groupsByLevel?.get(level) && this.groupsByLevel.get(level)![index]) {
const estimatedTeams: number = Math.ceil(this.totalTeams / this.groupsByLevel.get(0)!.length);
let teams: number = -1;
for (const i of this.groupsByLevel.get(level)!.keys()) {
Expand All @@ -81,7 +81,7 @@ export class TournamentBracketsComponent implements OnInit {
if (level == 0) {
return group * (BracketsMeasures.GROUP_SEPARATION + this.getGroupHigh(level, group));
}
if (groupsByLevel && groupsByLevel.get(0) && groupsByLevel.get(level)) {
if (groupsByLevel?.get(0) && groupsByLevel?.get(level)) {
const maxHeight: number = groupsByLevel.get(0)!.length * (this.getGroupHigh(0, group) + BracketsMeasures.GROUP_SEPARATION);
const portion: number = (maxHeight / groupsByLevel.get(level)!.length);
return (portion * (group + 1)) - portion / 2 - this.getGroupHigh(level, group) / 2 - BracketsMeasures.GROUP_SEPARATION / 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {CommonModule} from '@angular/common';
import {TournamentBracketsComponent} from "./tournament-brackets.component";
import {ArrowModule} from "./arrow/arrow.module";
import {DragDropModule} from "@angular/cdk/drag-drop";
import { GroupContainerComponent } from './group-container/group-container.component';
import {GroupContainerComponent} from './group-container/group-container.component';
import {TeamCardModule} from "../../team-card/team-card.module";
import {ShiaijoModule} from "./shiaijo/shiaijo.module";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,5 @@
border-style: solid;
box-shadow: 0 5px 10px 0 rgba(0, 18, 57, 0.5);
transition: transform .2s; /* Animation */
//Transform causes problem with the timer component z-index.
//transform: scale(1.03);
background: white;
}
4 changes: 2 additions & 2 deletions frontend/src/app/interceptors/invalid-jwt-interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from "@angular/common/http";
import {Observable, throwError} from "rxjs";
import {Observable} from "rxjs";
import {Router} from "@angular/router";
import {Injectable} from "@angular/core";
import {catchError} from "rxjs/operators";
Expand All @@ -15,7 +15,7 @@ export class InvalidJwtInterceptor implements HttpInterceptor {

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).pipe(
catchError((error) => {
catchError((error): void => {
//If on JWT, the IP is changed, launch a 409 error. 401 and 423 are for invalid or expired jwt. As Jwt is invalid now, logging again.
if (error.status === 409 || error.status === 401 || error.status === 423) {
this.loginService.logout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ export class LocalErrorHandler implements ErrorHandler {
//Show error
this.messageService.errorMessage(`Error connecting to the backend service. ${error.url} failed: ${error ? error.message : ""}`);
}
//this.loggerService.error(error.message);
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/interceptors/logged-in.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {inject, Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, CanActivate, CanActivateFn, Router, RouterStateSnapshot} from '@angular/router';
import {ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot} from '@angular/router';
import {LoginService} from "../services/login.service";
import {BehaviorSubject} from "rxjs";
import {TournamentService} from "../services/tournament.service";
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/app/models/league-fights-order.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {DrawResolution} from "./draw-resolution";

export enum LeagueFightsOrder {
FIFO = 'FIFO',
LIFO = 'LIFO',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/services/file.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders} from "@angular/common/http";
import {HttpClient} from "@angular/common/http";
import {EnvironmentService} from "../environment.service";
import {MessageService} from "./message.service";
import {LoggerService} from "./logger.service";
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/app/services/group-link.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import {LoggerService} from "./logger.service";
import {LoginService} from "./login.service";
import {SystemOverloadService} from "./notifications/system-overload.service";
import {Observable} from "rxjs";
import {Group} from "../models/group";
import {catchError, tap} from "rxjs/operators";
import {GroupLink} from "../models/group-link.model";
import {Tournament} from "../models/tournament";

@Injectable({
providedIn: 'root'
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/services/login.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {Router} from "@angular/router";
import {ActivityService} from "./rbac/activity.service";
import {AuthGuestRequest} from "./models/auth-guest-request";
import {TemporalToken} from "./models/temporal-token";
import {Participant} from "../models/participant";

@Injectable({
providedIn: 'root'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export class LeagueGeneratorComponent extends RbacBasedComponent implements OnIn

//Sort map and assign:
this.teamsOrder = [];
const sortedTeams: Map<number, Team> = new Map([...teamsScore.entries()].sort());
const sortedTeams: Map<number, Team> = new Map([...teamsScore.entries()].sort(
(a: [number, Team], b: [number, Team]) => a[0] - b[0]));
this.teamsOrder.push(...sortedTeams.values());
this.teamListData.teams = [];
this.teamListData.filteredTeams = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TournamentGeneratorComponent } from './tournament-generator.component';
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {TournamentGeneratorComponent} from './tournament-generator.component';
import {
TournamentBracketsEditorModule
} from "../../../components/tournament-brackets-editor/tournament-brackets-editor.module";
Expand All @@ -13,7 +13,6 @@ import {TranslateModule} from "@ngx-translate/core";
import {MatDividerModule} from "@angular/material/divider";



@NgModule({
declarations: [
TournamentGeneratorComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="gallery">
<div *ngFor="let image of pictures; let i = index" class="image-container">
<img (click)="selectImage(i)" (keydown)="selectImage(i)" [class.selected-image]="i === selectedPicture" alt="Participant's Picture"
<img (click)="selectImage(i)" (keydown)="selectImage(i)" [class.selected-image]="i === selectedPicture" alt="Participant"
src="{{ image }}"/>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/views/passwords/passwords.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Component, OnInit} from '@angular/core';
import {
AbstractControl,
UntypedFormControl,
UntypedFormGroup,
FormGroupDirective,
NgForm,
UntypedFormControl,
UntypedFormGroup,
ValidationErrors,
ValidatorFn,
Validators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Inject, OnInit, Optional} from '@angular/core';
import {Component, Inject, Optional} from '@angular/core';
import {RbacBasedComponent} from "../../../../components/RbacBasedComponent";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {Tournament} from "../../../../models/tournament";
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/assets/achievements/daruma.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions frontend/src/assets/achievements/first_blood.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions frontend/src/assets/achievements/love_sharing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 693b4d2

Please sign in to comment.