Skip to content

Commit 7d48427

Browse files
ClementBouvierNfreddidierRTE
authored andcommitted
Fixed most 'readonly' sonar issues (#7624)
Signed-off-by: ClementBouvierN <[email protected]>
1 parent e1c719a commit 7d48427

File tree

70 files changed

+206
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+206
-215
lines changed

ui/main/src/app/business/common/jsontoarray/json-to-array.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ export class JsonToArray {
4242
this.fieldsProcessOnlyIfPreviousArraysAreEmpty.add(rule.jsonField);
4343
rule.fields.forEach((field) => this.processRule(field, true));
4444
this.nestedJsonToArrays.set(rule.jsonField, new JsonToArray(rule.fields));
45-
} else {
46-
if (rule.columnName) {
47-
this.addColumn(rule.columnName);
48-
if (!innerRule)
49-
this.fieldDescriptions.push(
50-
new FieldDescription(rule.jsonField, rule.type, this.columnIndexes.get(rule.columnName), false)
51-
);
52-
}
45+
} else if (rule.columnName) {
46+
this.addColumn(rule.columnName);
47+
if (!innerRule)
48+
this.fieldDescriptions.push(
49+
new FieldDescription(rule.jsonField, rule.type, this.columnIndexes.get(rule.columnName), false)
50+
);
5351
}
5452
}
5553

ui/main/src/app/business/services/global-style.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {MenuService} from 'app/business/services/menu.service';
1515
declare const opfabStyle: any;
1616

1717
export class GlobalStyleService {
18-
public static DAY = 'DAY';
19-
public static NIGHT = 'NIGHT';
18+
public static readonly DAY = 'DAY';
19+
public static readonly NIGHT = 'NIGHT';
2020

2121
private static style: string;
2222

ui/main/src/app/business/view/notificationConfiguration/notificationConfiguration.view.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class NotificationConfigurationView {
3333
private setEmailEnabled: Function = () => {};
3434
private notificationConfigurationPage: NotificationConfigurationPage;
3535
private processList: ProcessForNotification[] = [];
36-
private translationService: TranslationService;
36+
private readonly translationService: TranslationService;
3737
private lastProcessesStatesNotNotifiedSaved;
3838
private lastProcessesStatesNotifiedByEmailSaved;
3939

ui/main/src/app/business/view/realtimeusers/realtimeusers.view.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ import {Utilities} from 'app/business/common/utilities';
2525

2626
export class RealtimeUsersView {
2727
private realtimePage: RealtimePage;
28-
private realtimeScreens: RealtimePageScreen[] = [];
29-
private connectedUsersPerEntity: Map<string, string[]> = new Map<string, string[]>();
30-
private connectedUsersGroups: Map<string, string[]> = new Map<string, string[]>();
31-
private pageLoaded = new ReplaySubject<RealtimePage>(1);
28+
private readonly realtimeScreens: RealtimePageScreen[] = [];
29+
private readonly connectedUsersPerEntity: Map<string, string[]> = new Map<string, string[]>();
30+
private readonly connectedUsersGroups: Map<string, string[]> = new Map<string, string[]>();
31+
private readonly pageLoaded = new ReplaySubject<RealtimePage>(1);
3232
private updateInterval;
3333

34-
constructor(private configServer: ConfigServer) {
34+
constructor(private readonly configServer: ConfigServer) {
3535
this.init();
3636
}
3737

ui/main/src/app/business/view/timeline/timeline.view.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ import {OpfabStore} from 'app/business/store/opfabStore';
1515
import {DateTimeFormatterService} from 'app/business/services/date-time-formatter.service';
1616

1717
export class TimelineView {
18-
private circles: Circles;
19-
private xAxis: XAxis;
18+
private readonly circles: Circles;
19+
private readonly xAxis: XAxis;
2020
private domainId: string;
2121
private title: string;
2222
private gridTimeDomain: any;
2323
private cardsTimeDomain: any;
24-
private ngUnsubscribe$ = new Subject<void>();
24+
private readonly ngUnsubscribe$ = new Subject<void>();
2525

26-
private circlesSubject = new Subject<Circle[]>();
27-
private filteredLightCardStore: FilteredLightCardsStore;
26+
private readonly circlesSubject = new Subject<Circle[]>();
27+
private readonly filteredLightCardStore: FilteredLightCardsStore;
2828

2929
constructor() {
3030
this.filteredLightCardStore = OpfabStore.getFilteredLightCardStore();

ui/main/src/app/business/view/timeline/xaxis.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class XAxis {
2323
private ticks: Array<Date> = [];
2424
private ticksLabel: Map<number, string> = new Map<number, string>();
2525

26-
private tickSizeMap = {
26+
private readonly tickSizeMap = {
2727
RT: {minutes: 15},
2828
J: {minutes: 30},
2929
'7D': {hours: 4},
@@ -111,7 +111,7 @@ export class XAxis {
111111
});
112112
}
113113

114-
private computeTickLabel = (value: Date, domainId: string): string => {
114+
private readonly computeTickLabel = (value: Date, domainId: string): string => {
115115
switch (domainId) {
116116
case 'RT':
117117
if (value.getMinutes() === 0) return DateTimeFormatterService.getFormattedDate(value, 'HH') + 'h';

ui/main/src/app/business/view/userCard/cardBuilder/cardBuilder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class CardBuilder {
2828
private editionMode: EditionMode;
2929
private endDate: number;
3030
private expirationDate: number;
31-
private inputFieldVisibility: Map<InputFieldName, boolean> = new Map();
31+
private readonly inputFieldVisibility: Map<InputFieldName, boolean> = new Map();
3232
private lttd: number;
3333
private processId: string;
3434
private processVersion: string;

ui/main/src/app/business/view/userCard/datesForm/datesForm.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {Card} from '@ofModel/card.model';
1414
import {CurrentUserCardAPI} from 'app/api/currentusercard.api';
1515

1616
export class DatesForm {
17-
private static ONE_MINUTE = 60000;
18-
private static ONE_DAY = 60000 * 60 * 24;
17+
private static readonly ONE_MINUTE = 60000;
18+
private static readonly ONE_DAY = 60000 * 60 * 24;
1919

2020
private endDate: number;
2121
private endDateVisible: boolean;
@@ -28,9 +28,9 @@ export class DatesForm {
2828
private startDateVisible: boolean;
2929
private stateId: string;
3030

31-
private dateFields = ['startDate', 'endDate', 'lttd', 'expirationDate'];
31+
private readonly dateFields = ['startDate', 'endDate', 'lttd', 'expirationDate'];
3232

33-
constructor(private userCardUIControl: UserCardUIControl) {}
33+
constructor(private readonly userCardUIControl: UserCardUIControl) {}
3434

3535
public initDatesBeforeTemplateScriptsExecution(
3636
processId: string,

ui/main/src/app/business/view/userCard/keepChildCardsForm/keepChildCardsForm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class KeepChildCardsForm {
1717
private keepChildCards: boolean;
1818
private keepChildCardsVisible: boolean = false;
1919

20-
constructor(private userCardUIControl: UserCardUIControl) {}
20+
constructor(private readonly userCardUIControl: UserCardUIControl) {}
2121

2222
public setValueAndVisibility(
2323
processId: string,

ui/main/src/app/business/view/userCard/processStatesForm/processStatesForm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class ProcessStatesForm {
4444
private selectedStateId: string;
4545
private currentCard: Card;
4646

47-
constructor(private userCardUIControl: UserCardUIControl) {}
47+
constructor(private readonly userCardUIControl: UserCardUIControl) {}
4848

4949
init(card: Card = undefined) {
5050
this.currentCard = card;

ui/main/src/app/business/view/userCard/publisherForm/publisherForm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class PublisherForm {
1919
private selectedPublisher: string;
2020
private editionMode: EditionMode;
2121

22-
constructor(private userCardUIControl: UserCardUIControl) {}
22+
constructor(private readonly userCardUIControl: UserCardUIControl) {}
2323

2424
public setProcessAndState(processId: string, stateId: string, card?: Card, editionMode?: EditionMode) {
2525
this.editionMode = editionMode;

ui/main/src/app/business/view/userCard/recipientsForm/recipientsForm.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export class RecipientsForm {
2424
private recipientVisible = false;
2525
private selectedRecipients: string[] = [];
2626
private selectedRecipientsForInformation: string[] = [];
27-
private useDescriptionFieldForEntityList = false;
27+
private readonly useDescriptionFieldForEntityList = false;
2828

29-
constructor(private userCardUIControl: UserCardUIControl) {
29+
constructor(private readonly userCardUIControl: UserCardUIControl) {
3030
this.useDescriptionFieldForEntityList = ConfigService.getConfigValue(
3131
'usercard.useDescriptionFieldForEntityList',
3232
false

ui/main/src/app/business/view/userCard/severityForm/severityForm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class SeverityForm {
1717
private selectedSeverity: Severity;
1818
private severityVisible: boolean;
1919

20-
constructor(private userCardUIControl: UserCardUIControl) {}
20+
constructor(private readonly userCardUIControl: UserCardUIControl) {}
2121

2222
public setProcessAndState(processId: string, stateId: string, card: Card = undefined) {
2323
const state = ProcessesService.getProcess(processId).states.get(stateId);

ui/main/src/app/business/view/userCard/userCard.view.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ export class UserCardView {
6868
private existingCard: Card;
6969
private existingChildCards: Card[];
7070
private datesForm: DatesForm;
71-
private processStatesForm: ProcessStatesForm;
72-
private publisherForm: PublisherForm;
71+
private readonly processStatesForm: ProcessStatesForm;
72+
private readonly publisherForm: PublisherForm;
7373
private recipientsForm: RecipientsForm;
74-
private severityForm: SeverityForm;
75-
private keepChildCardsForm: KeepChildCardsForm;
74+
private readonly severityForm: SeverityForm;
75+
private readonly keepChildCardsForm: KeepChildCardsForm;
7676
private useCurrentDateForCardStartDate: boolean;
7777

78-
constructor(private userCardUIControl: UserCardUIControl) {
78+
constructor(private readonly userCardUIControl: UserCardUIControl) {
7979
this.processStatesForm = new ProcessStatesForm(this.userCardUIControl);
8080
this.publisherForm = new PublisherForm(this.userCardUIControl);
8181
this.severityForm = new SeverityForm(this.userCardUIControl);

ui/main/src/app/business/view/useractionlogs/userActionLogs.view.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ import {UserActionLogsPageDescription} from './userActionLogsPageDescription';
2626
import {ExcelExport} from '../../common/excel-export';
2727

2828
export class UserActionLogsView {
29-
private userActionLogPage = new UserActionLogsPageDescription();
29+
private readonly userActionLogPage = new UserActionLogsPageDescription();
3030
private selectedLogins: string[] = [];
3131
private selectedActions: string[] = [];
3232
private dateFrom = 0;
3333
private dateTo = 0;
3434
private pageNumber = 0;
3535

3636
constructor(
37-
private translationService: TranslationService,
38-
private userActionLogsServer: UserActionLogsServer
37+
private readonly translationService: TranslationService,
38+
private readonly userActionLogsServer: UserActionLogsServer
3939
) {
4040
this.initPage();
4141
}

ui/main/src/app/modules/activityarea/activityarea.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export class ActivityareaComponent implements OnInit, OnDestroy {
4242
activityAreaView: ActivityAreaView;
4343
activityAreaPage: ActivityAreaPage;
4444

45-
private canDeactivateSubject = new Subject<boolean>();
46-
private ngUnsubscribe$ = new Subject<void>();
45+
private readonly canDeactivateSubject = new Subject<boolean>();
46+
private readonly ngUnsubscribe$ = new Subject<void>();
4747

48-
constructor(private modalService: NgbModal) {}
48+
constructor(private readonly modalService: NgbModal) {}
4949

5050
ngOnInit() {
5151
this.activityAreaView = new ActivityAreaView();

ui/main/src/app/modules/admin/admin.component.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
12-
import {ActivatedRoute, RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
12+
import {RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
1313
import {TranslateService, TranslateModule} from '@ngx-translate/core';
1414
import {SharingService} from './services/sharing.service';
1515
import {NgFor} from '@angular/common';
@@ -28,9 +28,8 @@ export class AdminComponent implements OnInit {
2828
public paginationPageSizeOptions = [5, 10, 25, 50, 100];
2929

3030
constructor(
31-
private route: ActivatedRoute,
3231
protected translate: TranslateService,
33-
private dataHandlingService: SharingService
32+
private readonly dataHandlingService: SharingService
3433
) {}
3534

3635
ngOnInit() {

ui/main/src/app/modules/admin/components/cell-renderers/action-cell-renderer.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class ActionCellRendererComponent implements ICellRendererAngularComp {
2727
public actionType: string;
2828

2929
// Defines icons to display depending on action type
30-
private actionIconsMapping = {
30+
private readonly actionIconsMapping = {
3131
edit: 'fas fa-pen',
3232
delete: 'far fa-trash-alt',
3333
download: 'fas fa-download',

ui/main/src/app/modules/admin/components/cell-renderers/role-cell-renderer.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class RoleCellRendererComponent implements ICellRendererAngularComp {
3030
entities: Entity[];
3131
_roles = [];
3232

33-
constructor(private translationService: TranslationService) {
33+
constructor(private readonly translationService: TranslationService) {
3434
this.entities = EntitiesService.getEntities();
3535
}
3636

ui/main/src/app/modules/admin/components/editmodal/entities/edit-entity-modal.component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ export class EditEntityModalComponent implements OnInit {
8484
private crudService: CrudService;
8585

8686
constructor(
87-
private translationService: TranslationService,
88-
private translate: TranslateService,
89-
private activeModal: NgbActiveModal,
90-
private dataHandlingService: SharingService,
91-
private changeDetector: ChangeDetectorRef
87+
private readonly translationService: TranslationService,
88+
private readonly translate: TranslateService,
89+
private readonly activeModal: NgbActiveModal,
90+
private readonly dataHandlingService: SharingService,
91+
private readonly changeDetector: ChangeDetectorRef
9292
) {}
9393

9494
ngOnInit() {

ui/main/src/app/modules/admin/components/editmodal/groups/edit-group-modal.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ export class EditGroupModalComponent implements OnInit {
8585
};
8686

8787
constructor(
88-
private activeModal: NgbActiveModal,
89-
private dataHandlingService: SharingService,
90-
private changeDetector: ChangeDetectorRef
88+
private readonly activeModal: NgbActiveModal,
89+
private readonly dataHandlingService: SharingService,
90+
private readonly changeDetector: ChangeDetectorRef
9191
) {
9292
Object.values(PermissionEnum).forEach((t) => this.groupPermissions.push({value: String(t), label: String(t)}));
9393
}

ui/main/src/app/modules/admin/components/editmodal/perimeters/edit-perimeter-modal.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import {MultiSelectComponent} from '../../../../share/multi-select/multi-select.
4040
})
4141
export class EditPerimeterModalComponent implements OnInit {
4242
constructor(
43-
private activeModal: NgbActiveModal,
44-
private changeDetector: ChangeDetectorRef
43+
private readonly activeModal: NgbActiveModal,
44+
private readonly changeDetector: ChangeDetectorRef
4545
) {
4646
Object.keys(RightsEnum).forEach((key) => {
4747
this.rightOptions.push({value: key, label: key});

ui/main/src/app/modules/admin/components/table/admin-table.directive.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ export abstract class AdminTableDirective implements OnDestroy {
9191

9292
protected i18NPrefix = 'admin.input.';
9393
protected crudService: CrudService;
94-
private currentUserLogin;
94+
private readonly currentUserLogin;
9595

9696
constructor(
9797
protected translateService: TranslateService,
9898
protected modalService: NgbModal,
9999
protected dataHandlingService: SharingService,
100-
private changeDetector: ChangeDetectorRef
100+
private readonly changeDetector: ChangeDetectorRef
101101
) {
102102
this.currentUserLogin = UserService.getCurrentUserWithPerimeters().userData.login;
103103
this.processesDefinition = ProcessesService.getAllProcesses();

ui/main/src/app/modules/admin/services/sharing.service.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import {CrudSupervisedEntitiesService} from 'app/business/services/admin/crud-su
2323
@Injectable()
2424
export class SharingService implements OnDestroy {
2525
private readonly _paginationPageSize$: ReplaySubject<number>;
26-
private unsubscribe$: Subject<void> = new Subject<void>();
27-
private crudUserService: CrudUserService;
28-
private crudEntitiesService: CrudEntitiesService;
29-
private crudGroupsService: CrudGroupsService;
30-
private crudPerimetersService: CrudPerimetersService;
31-
private crudProcessesService: CrudProcessesService;
32-
private crudBusinessDataService: CrudBusinessDataService;
33-
private supervisedEntitiesService: CrudSupervisedEntitiesService;
26+
private readonly unsubscribe$: Subject<void> = new Subject<void>();
27+
private readonly crudUserService: CrudUserService;
28+
private readonly crudEntitiesService: CrudEntitiesService;
29+
private readonly crudGroupsService: CrudGroupsService;
30+
private readonly crudPerimetersService: CrudPerimetersService;
31+
private readonly crudProcessesService: CrudProcessesService;
32+
private readonly crudBusinessDataService: CrudBusinessDataService;
33+
private readonly supervisedEntitiesService: CrudSupervisedEntitiesService;
3434

3535
constructor() {
3636
this._paginationPageSize$ = new ReplaySubject<number>();

ui/main/src/app/modules/archives/archives.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ export class ArchivesComponent implements OnDestroy, OnInit {
114114
displayContext: any = DisplayContext.ARCHIVE;
115115

116116
constructor(
117-
private translationService: TranslationService,
118-
private modalService: NgbModal,
119-
private changeDetector: ChangeDetectorRef
117+
private readonly translationService: TranslationService,
118+
private readonly modalService: NgbModal,
119+
private readonly changeDetector: ChangeDetectorRef
120120
) {
121121
ProcessesService.getAllProcesses().forEach((process) => {
122122
let itemName = process.name;

ui/main/src/app/modules/card/card.component.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,10 @@ export class CardComponent implements OnInit, OnDestroy {
8080
}
8181
}
8282
});
83-
} else {
84-
if (selectedCard.notFound) {
85-
this.cardNotFound = true;
86-
this.cardLoadingInProgress = false;
87-
LoggerService.warn('Card not found.');
88-
}
83+
} else if (selectedCard.notFound) {
84+
this.cardNotFound = true;
85+
this.cardLoadingInProgress = false;
86+
LoggerService.warn('Card not found.');
8987
}
9088
});
9189
this.checkForCardLoadingInProgressForMoreThanOneSecond();

ui/main/src/app/modules/card/components/card-ack/card-ack.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class CardAckComponent implements OnInit, OnChanges, OnDestroy {
5959

6060
public user: User;
6161

62-
private unsubscribe$: Subject<void> = new Subject<void>();
62+
private readonly unsubscribe$: Subject<void> = new Subject<void>();
6363
isReadOnlyUser: any;
6464

6565
cardProcess: Process;

0 commit comments

Comments
 (0)