From a1752f542203ea0fd2a871f00e43cc1b8c8b3fc9 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Thu, 25 Aug 2022 17:38:14 +0200 Subject: [PATCH 1/5] fix sonar smells --- .../claim-structure.component.ts | 2 +- .../manage-employers.component.ts | 6 +++--- .../manage-jobs/manage-jobs.component.ts | 6 +++--- .../manage-users/manage-users.component.ts | 4 ++-- .../newsletter-users.component.ts | 2 +- src/app/carto/carto.component.spec.ts | 3 +-- src/app/config/http-interceptor.ts | 6 +----- .../account-newsletter.component.ts | 2 +- .../form/form-view/form-view-routing.module.ts | 1 - src/app/form/form-view/form-view.component.ts | 17 ++++++++--------- .../personal-offer-training-type.component.scss | 0 .../personal-offer-training-type.component.ts | 1 - .../structure-consent.component.ts | 2 +- .../structure-covid-info.component.ts | 2 +- .../structure-name-and-address.component.scss | 0 .../structure-name-and-address.component.ts | 1 - .../structure-detail-print.component.ts | 2 +- .../orientation-form.component.ts | 4 ++-- src/app/guards/admin.guard.ts | 2 +- src/app/guards/auth.guard.ts | 2 +- src/app/guards/deactivate.guard.ts | 2 -- src/app/guards/login.guard.ts | 2 +- src/app/header/header.component.ts | 1 - src/app/login/login.component.scss | 1 - src/app/page/page.component.ts | 3 +-- .../post-header/post-header.component.ts | 2 +- .../post-modal-filters.component.ts | 5 +---- src/app/post/news.component.ts | 6 ++---- src/app/reset-email/reset-email.component.ts | 2 +- .../reset-password/reset-password.component.ts | 2 +- src/app/services/contact.service.ts | 2 +- src/app/services/newsletter.service.ts | 2 +- src/app/services/notification.service.ts | 2 +- .../checkbox-form/checkbox-form.component.ts | 6 ++---- .../create-account-form.component.ts | 1 - .../copy-paste/copy-paste.component.ts | 6 ++---- .../components/logo-card/logo-card.component.ts | 8 ++------ .../modal-options/modal-options.component.ts | 6 ++---- .../password-form/password-form.component.ts | 3 +-- .../radio-form/radio-form.component.ts | 2 -- .../structure-options-modal.component.ts | 2 +- .../structure-type-picker.component.scss | 8 +++----- .../training-type-picker.component.scss | 8 +++----- .../validator-form/validator-form.component.ts | 1 - src/app/shared/service/windowScroll.service.ts | 2 -- .../structure-details-modals.component.ts | 6 +++--- 46 files changed, 58 insertions(+), 98 deletions(-) delete mode 100644 src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.scss delete mode 100644 src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.scss diff --git a/src/app/admin/components/claim-structure/claim-structure.component.ts b/src/app/admin/components/claim-structure/claim-structure.component.ts index af6820d83..df55627f4 100644 --- a/src/app/admin/components/claim-structure/claim-structure.component.ts +++ b/src/app/admin/components/claim-structure/claim-structure.component.ts @@ -36,7 +36,7 @@ export class ClaimStructureComponent implements OnInit { }); } - public claimedStructure(event: boolean): void { + public claimedStructure(_event: boolean): void { this.isClaimedStructure = !this.isClaimedStructure; } } diff --git a/src/app/admin/components/manage-employers/manage-employers.component.ts b/src/app/admin/components/manage-employers/manage-employers.component.ts index 1d2d78d87..347f33871 100644 --- a/src/app/admin/components/manage-employers/manage-employers.component.ts +++ b/src/app/admin/components/manage-employers/manage-employers.component.ts @@ -18,7 +18,7 @@ export class ManageEmployersComponent implements OnInit { public validatedEmployers: Employer[] = []; public unvalidatedEmployers: Employer[] = []; public deleteModalOpenned = false; - public validatedEmployersName: String[] = []; + public validatedEmployersName: string[] = []; public mergeEmployerModalOpenned = false; public employerToDelete: Employer = null; public mergeOpe: any = { @@ -209,8 +209,8 @@ export class ManageEmployersComponent implements OnInit { } } - public validateEmployer(employerId: string, context?): void { - this.adminService.validateEmployer(employerId).subscribe((data) => { + public validateEmployer(employerId: string, _context?): void { + this.adminService.validateEmployer(employerId).subscribe((_data) => { this.findValidatedEmployers(); this.findUnvalidatedEmployers(); }); diff --git a/src/app/admin/components/manage-jobs/manage-jobs.component.ts b/src/app/admin/components/manage-jobs/manage-jobs.component.ts index d17baf4e2..59b86510d 100644 --- a/src/app/admin/components/manage-jobs/manage-jobs.component.ts +++ b/src/app/admin/components/manage-jobs/manage-jobs.component.ts @@ -20,7 +20,7 @@ export class ManageJobsComponent implements OnInit { public validatedJobs: Job[] = []; public unvalidatedJobs: Job[] = []; public deleteModalOpenned = false; - public validatedJobsName: String[] = []; + public validatedJobsName: string[] = []; public mergeJobModalOpenned = false; public jobToDelete: Job = null; public mergeOpe: any = { @@ -246,8 +246,8 @@ export class ManageJobsComponent implements OnInit { } } - public validateJob(jobId: string, context?): void { - this.adminService.validateJob(jobId).subscribe((data) => { + public validateJob(jobId: string, _context?): void { + this.adminService.validateJob(jobId).subscribe((_data) => { this.findValidatedJobs(); this.findUnvalidatedJobs(); }); diff --git a/src/app/admin/components/manage-users/manage-users.component.ts b/src/app/admin/components/manage-users/manage-users.component.ts index 37eb41805..fc999f9d0 100644 --- a/src/app/admin/components/manage-users/manage-users.component.ts +++ b/src/app/admin/components/manage-users/manage-users.component.ts @@ -18,9 +18,9 @@ export class ManageUsersComponent { public attachedUsers: User[] = []; public unAttachedUsers: User[] = []; public unVerifiedUsers: User[] = []; - public validatedJobsName: String[] = []; + public validatedJobsName: string[] = []; public validatedJobs: Job[] = []; - public validatedEmployersName: String[] = []; + public validatedEmployersName: string[] = []; public validatedEmployers: Employer[] = []; public deleteModalOpenned = false; public editJobModalOpenned = false; diff --git a/src/app/admin/components/newsletter-users/newsletter-users.component.ts b/src/app/admin/components/newsletter-users/newsletter-users.component.ts index 2b8675165..73b142f9e 100644 --- a/src/app/admin/components/newsletter-users/newsletter-users.component.ts +++ b/src/app/admin/components/newsletter-users/newsletter-users.component.ts @@ -34,7 +34,7 @@ export class NewsletterUsersComponent { public unsubscribeEmail(email: string, shouldUnsubscribe: boolean): void { this.toggleUnsubscribeModal(email); if (shouldUnsubscribe) { - this.adminService.unsubscribeEmail(email).subscribe((data) => { + this.adminService.unsubscribeEmail(email).subscribe((_data) => { this.subscriptions = this.subscriptions.filter((obj) => obj.email !== email); this.subscriptionsCount = this.subscriptions.length; }); diff --git a/src/app/carto/carto.component.spec.ts b/src/app/carto/carto.component.spec.ts index c97da2f6a..1a7b809cf 100644 --- a/src/app/carto/carto.component.spec.ts +++ b/src/app/carto/carto.component.spec.ts @@ -33,7 +33,7 @@ describe('HomeComponent', () => { it('getAddress(): should getAddress', () => { spyOn(navigator.geolocation, 'getCurrentPosition').and.callFake(() => { - const position = { + return { coords: { accuracy: 1490, altitude: null, @@ -44,7 +44,6 @@ describe('HomeComponent', () => { speed: null, }, }; - return position; }); component.getLocation(); expect(navigator.geolocation.getCurrentPosition).toHaveBeenCalled(); diff --git a/src/app/config/http-interceptor.ts b/src/app/config/http-interceptor.ts index d4911dbb9..35d410b71 100644 --- a/src/app/config/http-interceptor.ts +++ b/src/app/config/http-interceptor.ts @@ -1,10 +1,6 @@ import { Observable } from 'rxjs'; import { Injectable } from '@angular/core'; -import { HttpInterceptor } from '@angular/common/http'; -import { HttpRequest } from '@angular/common/http'; -import { HttpHandler } from '@angular/common/http'; -import { HttpEvent } from '@angular/common/http'; -import { HttpHeaders } from '@angular/common/http'; +import { HttpInterceptor, HttpHandler, HttpEvent, HttpRequest, HttpHeaders } from '@angular/common/http'; import { AuthService } from '../services/auth.service'; @Injectable() diff --git a/src/app/form/form-view/account-form/account-newsletter/account-newsletter.component.ts b/src/app/form/form-view/account-form/account-newsletter/account-newsletter.component.ts index 6b61b9245..25befd153 100644 --- a/src/app/form/form-view/account-form/account-newsletter/account-newsletter.component.ts +++ b/src/app/form/form-view/account-form/account-newsletter/account-newsletter.component.ts @@ -10,7 +10,7 @@ export class AccountNewsletterComponent { @Input() accountForm: FormGroup; @Input() profile: User; @Output() acceptNewsletter = new EventEmitter<any>(); - public userAcceptNewsletter: Boolean = false; + public userAcceptNewsletter: boolean = false; public acceptReceiveNewsletter(accepts: boolean) { this.acceptNewsletter.emit(accepts); diff --git a/src/app/form/form-view/form-view-routing.module.ts b/src/app/form/form-view/form-view-routing.module.ts index 9768d97d6..12765adf2 100644 --- a/src/app/form/form-view/form-view-routing.module.ts +++ b/src/app/form/form-view/form-view-routing.module.ts @@ -1,6 +1,5 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import { AdminGuard } from '../../guards/admin.guard'; import { AuthGuard } from '../../guards/auth.guard'; import { RoleGuard } from '../../guards/role.guard'; import { StructureResolver } from '../../resolvers/structure.resolver'; diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index a2d8a24c7..89a08f75f 100644 --- a/src/app/form/form-view/form-view.component.ts +++ b/src/app/form/form-view/form-view.component.ts @@ -19,6 +19,8 @@ import { personalOfferFormStep } from './personal-offer-form/personalOfferFormSt import { profileFormStep } from './profile-form/profileFormStep.enum'; import { structureFormStep } from './structure-form/structureFormStep.enum'; +type stepType = accountFormStep | profileFormStep | structureFormStep | personalOfferFormStep; + @Component({ selector: 'app-form-view', templateUrl: './form-view.component.html', @@ -27,7 +29,7 @@ import { structureFormStep } from './structure-form/structureFormStep.enum'; export class FormViewComponent implements OnInit { public routeParam: string; public formType = formType; - public currentPage: accountFormStep | profileFormStep | structureFormStep | personalOfferFormStep; + public currentPage: stepType; public currentFormType: formType; public currentForm: FormGroup; public formUtils = new formUtils(); @@ -261,10 +263,7 @@ export class FormViewComponent implements OnInit { }); } - public async endForm(type: { - formType: formType; - formStep?: accountFormStep | profileFormStep | structureFormStep | personalOfferFormStep; - }): Promise<void> { + public async endForm(type: { formType: formType; formStep?: stepType }): Promise<void> { switch (type.formType) { case formType.account: break; @@ -308,17 +307,17 @@ export class FormViewComponent implements OnInit { forkJoin({ employer: this.profileService.createEmployer(this.profileForm.get('employer').value).pipe( map((res) => res), - catchError((e) => of(this.profileForm.get('employer').value)) + catchError((_e) => of(this.profileForm.get('employer').value)) ), job: this.profileService.createJob(this.profileForm.get('job').value).pipe( map((res) => res), - catchError((e) => of(this.profileForm.get('job').value)) + catchError((_e) => of(this.profileForm.get('job').value)) ), profile: this.profileService .updateProfile(this.profileForm.get('employer').value.name, this.profileForm.get('job').value.name) .pipe( map((res) => res), - catchError((e) => of()) + catchError((_e) => of()) ), }).subscribe(() => { this.router.navigateByUrl('form/structure'); @@ -345,7 +344,7 @@ export class FormViewComponent implements OnInit { } }); } - public setCurrentStep(step: accountFormStep | profileFormStep | structureFormStep | personalOfferFormStep): void { + public setCurrentStep(step: stepType): void { //THIS PROBABLY CREATES CONSOLE ERRORS NG100 only in dev mode, please refer to https://angular.io/errors/NG0100 for more info this.currentPage = step; } diff --git a/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.scss b/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.ts b/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.ts index 5524913cb..e28e3863f 100644 --- a/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.ts +++ b/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.ts @@ -5,7 +5,6 @@ import { Category } from '@gouvfr-anct/mediation-numerique'; @Component({ selector: 'app-personal-offer-training-type', templateUrl: './personal-offer-training-type.component.html', - styleUrls: ['./personal-offer-training-type.component.scss'], }) export class PersonalOfferTrainingTypeComponent { @Input() structureName: string; diff --git a/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.ts b/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.ts index fc907cb7a..a4f3a5263 100644 --- a/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.ts +++ b/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; import { FormGroup } from '@angular/forms'; @Component({ diff --git a/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.ts b/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.ts index f4d379d64..448a906a8 100644 --- a/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.ts +++ b/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { AbstractControl, FormGroup } from '@angular/forms'; @Component({ diff --git a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.scss b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts index 471f94bfc..0ef99b6d8 100644 --- a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts +++ b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts @@ -5,7 +5,6 @@ import { Address } from '@gouvfr-anct/mediation-numerique'; @Component({ selector: 'app-structure-name-and-address', templateUrl: './structure-name-and-address.component.html', - styleUrls: ['./structure-name-and-address.component.scss'], }) export class StructureNameAndAddressComponent implements OnInit { @Input() structureForm: FormGroup; diff --git a/src/app/form/orientation-form/component/structure-detail-print/structure-detail-print.component.ts b/src/app/form/orientation-form/component/structure-detail-print/structure-detail-print.component.ts index 0e6018975..f8d1c4b80 100644 --- a/src/app/form/orientation-form/component/structure-detail-print/structure-detail-print.component.ts +++ b/src/app/form/orientation-form/component/structure-detail-print/structure-detail-print.component.ts @@ -28,7 +28,7 @@ export class StructureDetailPrintComponent implements OnInit { } } - public keepOriginalOrder = (a, b) => a.key; + public keepOriginalOrder = (a, _b) => a.key; public userIsLoggedIn(): boolean { return this.authService.isLoggedIn(); diff --git a/src/app/form/orientation-form/orientation-form.component.ts b/src/app/form/orientation-form/orientation-form.component.ts index 2c9349de8..0284bb8a7 100644 --- a/src/app/form/orientation-form/orientation-form.component.ts +++ b/src/app/form/orientation-form/orientation-form.component.ts @@ -441,7 +441,7 @@ export class OrientationFormComponent implements OnInit { this.orientationForm.value.address.postcode ? this.orientationForm.value.address.postcode : '69000' ) .subscribe((res) => { - this.structureService.getStructures(this.filters.filter((elem) => elem.checked == true)).subscribe((data) => { + this.structureService.getStructures(this.filters.filter((elem) => elem.checked)).subscribe((data) => { data.map((structure) => { structure.distance = parseInt( this.geoJsonService.getDistance( @@ -480,7 +480,7 @@ export class OrientationFormComponent implements OnInit { this.setValidationsForm(); } - public isInPrintList(id: String): boolean { + public isInPrintList(id: string): boolean { return this.structuresToPrint.findIndex((elem) => elem._id == id) > -1 ? true : false; } diff --git a/src/app/guards/admin.guard.ts b/src/app/guards/admin.guard.ts index 2f00de8ac..7d07a4d86 100644 --- a/src/app/guards/admin.guard.ts +++ b/src/app/guards/admin.guard.ts @@ -9,7 +9,7 @@ import { ProfileService } from '../profile/services/profile.service'; export class AdminGuard implements CanActivate { constructor(private authService: AuthService, private router: Router, private profileService: ProfileService) {} - canActivate(route: ActivatedRouteSnapshot): UrlTree | boolean { + canActivate(_route: ActivatedRouteSnapshot): UrlTree | boolean { if (this.authService.isLoggedIn() && this.profileService.isAdmin()) { return true; } diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index 9c7fb4ab2..d77c855f4 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -8,7 +8,7 @@ import { AuthService } from '../services/auth.service'; export class AuthGuard implements CanActivate { constructor(private authService: AuthService, private router: Router) {} - canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { + canActivate(_next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { if (this.authService.isLoggedIn()) { return true; } diff --git a/src/app/guards/deactivate.guard.ts b/src/app/guards/deactivate.guard.ts index 3f86e0502..e9f65a50a 100644 --- a/src/app/guards/deactivate.guard.ts +++ b/src/app/guards/deactivate.guard.ts @@ -13,8 +13,6 @@ export interface IDeactivateComponent { export class DeactivateGuard implements CanDeactivate<Object> { component: Object; - constructor() {} - canDeactivate(component: IDeactivateComponent): Observable<boolean> | Promise<boolean> | boolean { return component.canExit(); } diff --git a/src/app/guards/login.guard.ts b/src/app/guards/login.guard.ts index 6f0c2d37b..b2d8e5b7f 100644 --- a/src/app/guards/login.guard.ts +++ b/src/app/guards/login.guard.ts @@ -8,7 +8,7 @@ import { AuthService } from '../services/auth.service'; export class LoginGuard implements CanActivate { constructor(private authService: AuthService, private router: Router) {} - canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { + canActivate(_next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { if (this.authService.isLoggedIn()) { return true; } diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index fe45be0c6..2b26546e1 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -48,7 +48,6 @@ export class HeaderComponent implements OnInit { } }); } - ngOnInit(): void {} public openMenu(): void { this.showMenu = true; diff --git a/src/app/login/login.component.scss b/src/app/login/login.component.scss index 3141ec4b0..be30b5475 100644 --- a/src/app/login/login.component.scss +++ b/src/app/login/login.component.scss @@ -2,7 +2,6 @@ @import '../../assets/scss/breakpoint'; @import '../../assets/scss/layout'; @import '../../assets/scss/typography'; -@import '../../assets/scss/layout'; .content { display: flex; diff --git a/src/app/page/page.component.ts b/src/app/page/page.component.ts index 3915c1523..7a4f4f7b5 100644 --- a/src/app/page/page.component.ts +++ b/src/app/page/page.component.ts @@ -1,7 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { DomSanitizer } from '@angular/platform-browser'; -import { Meta } from '@angular/platform-browser'; +import { DomSanitizer, Meta } from '@angular/platform-browser'; import packageJson from '../../../package.json'; import { Page } from './models/page.model'; import { PageService } from './services/page.service'; diff --git a/src/app/post/components/post-header/post-header.component.ts b/src/app/post/components/post-header/post-header.component.ts index 5d1d62907..bf08e25e0 100644 --- a/src/app/post/components/post-header/post-header.component.ts +++ b/src/app/post/components/post-header/post-header.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, OnInit, Output } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { Tag } from '../../models/tag.model'; import { TagWithMeta } from '../../models/tagWithMeta.model'; import { TypeModalNews } from '../../enum/typeModalNews.enum'; diff --git a/src/app/post/components/post-modal-filters/post-modal-filters.component.ts b/src/app/post/components/post-modal-filters/post-modal-filters.component.ts index 6624c5d0e..5b1b37504 100644 --- a/src/app/post/components/post-modal-filters/post-modal-filters.component.ts +++ b/src/app/post/components/post-modal-filters/post-modal-filters.component.ts @@ -1,7 +1,6 @@ -import { Component, EventEmitter, Input, OnInit, Output, SimpleChanges } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import { Tag } from '../../models/tag.model'; import { TypeModalNews } from '../../enum/typeModalNews.enum'; -import { OnChanges } from '@angular/core'; @Component({ selector: 'app-post-modal-filters', @@ -17,8 +16,6 @@ export class PostModalFiltersComponent implements OnInit, OnChanges { @Input() public inputCheckedTags: Tag[] = []; public checkedTags: Tag[] = []; - constructor() {} - ngOnChanges(changes: SimpleChanges): void { if (changes.inputCheckedTags) { this.checkedTags = this.inputCheckedTags; diff --git a/src/app/post/news.component.ts b/src/app/post/news.component.ts index 36d434376..ef079107f 100644 --- a/src/app/post/news.component.ts +++ b/src/app/post/news.component.ts @@ -1,16 +1,14 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { Tag } from './models/tag.model'; @Component({ selector: 'app-news', templateUrl: './news.component.html', }) -export class NewsComponent implements OnInit { +export class NewsComponent { public filters: Tag[]; constructor() {} - ngOnInit(): void {} - public setFilters(tags: Tag[]): void { this.filters = tags; } diff --git a/src/app/reset-email/reset-email.component.ts b/src/app/reset-email/reset-email.component.ts index 705a40ecc..4e4cd3c05 100644 --- a/src/app/reset-email/reset-email.component.ts +++ b/src/app/reset-email/reset-email.component.ts @@ -29,7 +29,7 @@ export class ResetEmailComponent implements OnInit { this.changeSuccess = true; this.authService.logout(); }, - (err) => { + (_err) => { this.changeSuccess = false; } ); diff --git a/src/app/reset-password/reset-password.component.ts b/src/app/reset-password/reset-password.component.ts index 9349fed69..98b7c3b8b 100644 --- a/src/app/reset-password/reset-password.component.ts +++ b/src/app/reset-password/reset-password.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { ActivatedRoute, Router } from '@angular/router'; +import { Router } from '@angular/router'; import { ButtonType } from '@gouvfr-anct/mediation-numerique/shared'; import { AuthService } from '../services/auth.service'; import { NotificationService } from '../services/notification.service'; diff --git a/src/app/services/contact.service.ts b/src/app/services/contact.service.ts index 8fb8cd523..3ad5bd86f 100644 --- a/src/app/services/contact.service.ts +++ b/src/app/services/contact.service.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Observable, of } from 'rxjs'; +import { Observable } from 'rxjs'; import { ContactMessage } from '../models/contact-message.model'; @Injectable({ diff --git a/src/app/services/newsletter.service.ts b/src/app/services/newsletter.service.ts index d90bd565d..f4a0131ff 100644 --- a/src/app/services/newsletter.service.ts +++ b/src/app/services/newsletter.service.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Observable, of } from 'rxjs'; +import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root', diff --git a/src/app/services/notification.service.ts b/src/app/services/notification.service.ts index 5b491fd86..0dee1c7b4 100644 --- a/src/app/services/notification.service.ts +++ b/src/app/services/notification.service.ts @@ -31,7 +31,7 @@ export class NotificationService { } ); - update.onTap.subscribe((action) => { + update.onTap.subscribe((_action) => { window.location.reload(); }); } diff --git a/src/app/shared/components/checkbox-form/checkbox-form.component.ts b/src/app/shared/components/checkbox-form/checkbox-form.component.ts index 690178ae4..33fbfb6f6 100644 --- a/src/app/shared/components/checkbox-form/checkbox-form.component.ts +++ b/src/app/shared/components/checkbox-form/checkbox-form.component.ts @@ -1,11 +1,11 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; @Component({ selector: 'app-checkbox-form', templateUrl: './checkbox-form.component.html', styleUrls: ['./checkbox-form.component.scss'], }) -export class CheckboxFormComponent implements OnInit { +export class CheckboxFormComponent { @Input() public isChecked = false; @Input() public text: string; @Input() public iconSvg: string; @@ -13,8 +13,6 @@ export class CheckboxFormComponent implements OnInit { @Output() checkEvent: EventEmitter<boolean> = new EventEmitter<boolean>(); constructor() {} - ngOnInit(): void {} - public clicked(): void { this.isChecked = !this.isChecked; this.checkEvent.emit(this.isChecked); diff --git a/src/app/shared/components/create-account-form/create-account-form.component.ts b/src/app/shared/components/create-account-form/create-account-form.component.ts index 5d3d73098..7e5af34f8 100644 --- a/src/app/shared/components/create-account-form/create-account-form.component.ts +++ b/src/app/shared/components/create-account-form/create-account-form.component.ts @@ -9,7 +9,6 @@ import { MustMatch } from '../../validator/form'; styleUrls: ['./create-account-form.component.scss'], }) export class CreateAccountFormComponent implements OnInit { - constructor() {} public accountForm: FormGroup; public submitted: boolean = false; public isShowConfirmPassword = false; diff --git a/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts b/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts index 9240f96d1..40b476962 100644 --- a/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts +++ b/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts @@ -1,11 +1,11 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; @Component({ selector: 'app-copy-paste', templateUrl: './copy-paste.component.html', styleUrls: ['./copy-paste.component.scss'], }) -export class CopyPasteComponent implements OnInit { +export class CopyPasteComponent { @Input() copiedDayName = ''; @Input() day = null; @@ -14,8 +14,6 @@ export class CopyPasteComponent implements OnInit { @Output() pasteEvent = new EventEmitter<any>(); constructor() {} - ngOnInit(): void {} - public copy(): void { this.copyEvent.emit(this.day); } diff --git a/src/app/shared/components/logo-card/logo-card.component.ts b/src/app/shared/components/logo-card/logo-card.component.ts index 718e6ba20..69699d655 100644 --- a/src/app/shared/components/logo-card/logo-card.component.ts +++ b/src/app/shared/components/logo-card/logo-card.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { Demarches } from '../../enum/demarches.enum'; import { Labels } from '../../enum/labels.enum'; @@ -7,14 +7,10 @@ import { Labels } from '../../enum/labels.enum'; templateUrl: './logo-card.component.html', styleUrls: ['./logo-card.component.scss'], }) -export class LogoCardComponent implements OnInit { +export class LogoCardComponent { @Input() public logoPath: string; @Input() public name: string; - constructor() {} - - ngOnInit(): void {} - public getName(key: string): string { if (Labels[key]) { return Labels[key]; diff --git a/src/app/shared/components/modal-options/modal-options.component.ts b/src/app/shared/components/modal-options/modal-options.component.ts index 4de502a5c..a4a23d9e9 100644 --- a/src/app/shared/components/modal-options/modal-options.component.ts +++ b/src/app/shared/components/modal-options/modal-options.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; import { FunctionTypeModalOptions } from '../../enum/functionTypeModalOptions.enum'; @Component({ @@ -6,15 +6,13 @@ import { FunctionTypeModalOptions } from '../../enum/functionTypeModalOptions.en templateUrl: './modal-options.component.html', styleUrls: ['./modal-options.component.scss'], }) -export class ModalOptionsComponent implements OnInit { +export class ModalOptionsComponent { functionType = FunctionTypeModalOptions; - constructor() {} @Input() isModalProfileOpts = false; @Input() hasOwners = true; @Input() public isEditFormView? = false; @Output() closed = new EventEmitter<number>(); - ngOnInit(): void {} public closeModal(value: number): void { this.closed.emit(value); diff --git a/src/app/shared/components/password-form/password-form.component.ts b/src/app/shared/components/password-form/password-form.component.ts index d1c449044..a24ca05cb 100644 --- a/src/app/shared/components/password-form/password-form.component.ts +++ b/src/app/shared/components/password-form/password-form.component.ts @@ -115,7 +115,6 @@ export class PasswordFormComponent implements OnInit { // stop here if form is invalid if (this.oldPasswordNeeded && !this.checkOldPassword(this.accountForm.value.oldPassword)) { this.passwordError = true; - return; } else if (this.oldPasswordNeeded) { // stop here if form is invalid this.passwordError = false; @@ -123,7 +122,7 @@ export class PasswordFormComponent implements OnInit { () => { this.passwordError = false; }, - (error) => { + (_error) => { this.passwordError = true; } ); diff --git a/src/app/shared/components/radio-form/radio-form.component.ts b/src/app/shared/components/radio-form/radio-form.component.ts index 503a12687..310137f81 100644 --- a/src/app/shared/components/radio-form/radio-form.component.ts +++ b/src/app/shared/components/radio-form/radio-form.component.ts @@ -7,8 +7,6 @@ import { Observable, Subscription } from 'rxjs'; styleUrls: ['./radio-form.component.scss'], }) export class RadioFormComponent implements OnInit { - constructor() {} - @Input() public selectedOption: boolean | string; @Input() public horizontal: boolean; @Input() public layoutGap: string; diff --git a/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts b/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts index 0090b3115..5b603a293 100644 --- a/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts +++ b/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts @@ -158,7 +158,7 @@ export class StructureOptionsModalComponent implements OnInit { this.closeModalOptsProfile(); this.formAddAccount.reset(); }, - (err) => { + (_err) => { this.ownerAlreadyLinked = true; } ); diff --git a/src/app/shared/components/structure-type-picker/structure-type-picker.component.scss b/src/app/shared/components/structure-type-picker/structure-type-picker.component.scss index 8fea868d5..54f998d04 100644 --- a/src/app/shared/components/structure-type-picker/structure-type-picker.component.scss +++ b/src/app/shared/components/structure-type-picker/structure-type-picker.component.scss @@ -93,6 +93,9 @@ svg { user-select: none; } .collapseHeader { + height: 65px; + padding: 0 15px 0 12px; + cursor: pointer; .titleCollapse { width: 100%; @include lato-bold-14; @@ -108,11 +111,6 @@ svg { } } } - .collapseHeader { - height: 65px; - padding: 0 15px 0 12px; - cursor: pointer; - } .logo { height: 24px; width: 24px; diff --git a/src/app/shared/components/training-type-picker/training-type-picker.component.scss b/src/app/shared/components/training-type-picker/training-type-picker.component.scss index 9d3339106..268d65ca4 100644 --- a/src/app/shared/components/training-type-picker/training-type-picker.component.scss +++ b/src/app/shared/components/training-type-picker/training-type-picker.component.scss @@ -96,6 +96,9 @@ button { } } .collapseHeader { + height: 65px; + padding: 0 15px 0 12px; + cursor: pointer; .titleCollapse { width: 100%; @include lato-bold-14; @@ -111,11 +114,6 @@ button { } } } - .collapseHeader { - height: 65px; - padding: 0 15px 0 12px; - cursor: pointer; - } .logo { height: 24px; width: 24px; diff --git a/src/app/shared/components/validator-form/validator-form.component.ts b/src/app/shared/components/validator-form/validator-form.component.ts index cc10fe185..53aa3ff7f 100644 --- a/src/app/shared/components/validator-form/validator-form.component.ts +++ b/src/app/shared/components/validator-form/validator-form.component.ts @@ -11,7 +11,6 @@ export class ValidatorFormComponent implements OnInit { @Input() public nameControl?: string; public errorPattern = 'Champ mal renseigné'; public errorMustMatch = 'Champ non identique'; - constructor() {} ngOnInit() { if (this.nameControl == 'password') { diff --git a/src/app/shared/service/windowScroll.service.ts b/src/app/shared/service/windowScroll.service.ts index ebdf325b8..cdd0342c7 100644 --- a/src/app/shared/service/windowScroll.service.ts +++ b/src/app/shared/service/windowScroll.service.ts @@ -8,8 +8,6 @@ export class WindowScrollService { scrollY = new BehaviorSubject(null); scrollY$ = this.scrollY.asObservable(); - constructor() {} - public updateScrollY(value: Event): void { this.scrollY.next(value); } diff --git a/src/app/structure/components/structure-details-modals/structure-details-modals.component.ts b/src/app/structure/components/structure-details-modals/structure-details-modals.component.ts index f88963308..f504eb5aa 100644 --- a/src/app/structure/components/structure-details-modals/structure-details-modals.component.ts +++ b/src/app/structure/components/structure-details-modals/structure-details-modals.component.ts @@ -62,7 +62,7 @@ export class StructureDetailsModalsComponent { public deleteStructure(shouldDelete: boolean): void { this.toggleDeleteModal(); if (shouldDelete) { - this.structureService.delete(this.structure._id).subscribe((res) => { + this.structureService.delete(this.structure._id).subscribe((_res) => { this.reload(); }); } @@ -71,8 +71,8 @@ export class StructureDetailsModalsComponent { public joinStructure(shouldClaim: boolean): void { this.toggleJoinModal(); if (shouldClaim) { - this.structureService.joinStructure(this.structure._id, this.authService.userValue.username).subscribe((res) => { - this.profileService.getProfile().then((user: User) => { + this.structureService.joinStructure(this.structure._id, this.authService.userValue.username).subscribe((_res) => { + this.profileService.getProfile().then((_user: User) => { this.claimChange.emit(true); }); }); -- GitLab From 7a7c86df80648a9337dab228eda2e6987ae08ea6 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Thu, 25 Aug 2022 17:44:15 +0200 Subject: [PATCH 2/5] fix build --- src/app/header/header.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index 2b26546e1..34c597c03 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -1,5 +1,5 @@ import { animate, animateChild, query, style, transition, trigger } from '@angular/animations'; -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { NavigationEnd, Router } from '@angular/router'; import { Structure } from '@gouvfr-anct/mediation-numerique'; import { ButtonType } from '@gouvfr-anct/mediation-numerique/shared'; @@ -30,7 +30,7 @@ import { AuthService } from '../services/auth.service'; ]), ], }) -export class HeaderComponent implements OnInit { +export class HeaderComponent { public showMenu = false; public showProfileMenu = false; public currentRoute = ''; -- GitLab From f627567d7b8ca868fce3e9e3345da871cad4e1f0 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Fri, 26 Aug 2022 10:18:14 +0200 Subject: [PATCH 3/5] test failing pipeline --- src/app/form/orientation-form/orientation-form.component.scss | 4 ++++ src/app/post/news.component.ts | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/form/orientation-form/orientation-form.component.scss b/src/app/form/orientation-form/orientation-form.component.scss index 03d833c99..d2945fd53 100644 --- a/src/app/form/orientation-form/orientation-form.component.scss +++ b/src/app/form/orientation-form/orientation-form.component.scss @@ -285,6 +285,10 @@ img { margin-left: 25%; margin-right: 24%; + app-recipe-preview { + color: white; + } + @media #{$tablet} { width: 100%; height: 100vh !important; diff --git a/src/app/post/news.component.ts b/src/app/post/news.component.ts index ef079107f..018a0b440 100644 --- a/src/app/post/news.component.ts +++ b/src/app/post/news.component.ts @@ -7,7 +7,6 @@ import { Tag } from './models/tag.model'; }) export class NewsComponent { public filters: Tag[]; - constructor() {} public setFilters(tags: Tag[]): void { this.filters = tags; -- GitLab From 4137303af046eb717172190c55e440dd0efe2f2e Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Fri, 26 Aug 2022 10:36:12 +0200 Subject: [PATCH 4/5] test pipeline --- .../hour-picker/copy-paste/copy-paste.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts b/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts index 40b476962..3c8132aaf 100644 --- a/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts +++ b/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts @@ -12,7 +12,12 @@ export class CopyPasteComponent { @Output() copyEvent = new EventEmitter<any>(); @Output() cancelEvent = new EventEmitter<any>(); @Output() pasteEvent = new EventEmitter<any>(); - constructor() {} + constructor() { + var myarray = [80, 3, 9, 34, 23, 5, 1]; + + myarray.sort(); + console.log(myarray); + } public copy(): void { this.copyEvent.emit(this.day); -- GitLab From cb6d1aa3d3cf78624922b65683d41a40b92f3453 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Fri, 26 Aug 2022 10:43:51 +0200 Subject: [PATCH 5/5] more smells --- .../orientation-form.component.scss | 56 ++++++++----------- .../post-list/post-list.component.ts | 2 +- .../checkbox-form/checkbox-form.component.ts | 1 - .../data-share-consent.component.ts | 2 +- .../copy-paste/copy-paste.component.ts | 6 -- .../training-type-picker.component.scss | 41 +++++--------- 6 files changed, 39 insertions(+), 69 deletions(-) diff --git a/src/app/form/orientation-form/orientation-form.component.scss b/src/app/form/orientation-form/orientation-form.component.scss index d2945fd53..153e46945 100644 --- a/src/app/form/orientation-form/orientation-form.component.scss +++ b/src/app/form/orientation-form/orientation-form.component.scss @@ -26,10 +26,22 @@ h4 { } .content { + height: 100% !important; + background-color: $white; + margin-left: 25%; + margin-right: 24%; padding: 0 16px; display: block; overflow-y: auto; - height: auto; + + @media #{$tablet} { + width: 100%; + height: 100vh !important; + margin: 0; + border-bottom: $grey-4 solid 1px; + min-height: unset; + } + h3 { @include lato-bold-26; @@ -64,6 +76,16 @@ h4 { color: $grey-1; @include lato-regular-14; margin: 7px 0 0 0; + &.notRequired { + font-size: 14px; + margin-top: 0px; + font-style: italic; + color: $primary-color; + + &.lg { + font-size: 17px; + } + } } .textareaBlock { @media #{$tablet} { @@ -279,38 +301,6 @@ img { background-color: $grey-8; } -.content { - height: 100% !important; - background-color: $white; - margin-left: 25%; - margin-right: 24%; - - app-recipe-preview { - color: white; - } - - @media #{$tablet} { - width: 100%; - height: 100vh !important; - margin: 0; - border-bottom: $grey-4 solid 1px; - min-height: unset; - } - - p { - &.notRequired { - font-size: 14px; - margin-top: 0px; - font-style: italic; - color: $primary-color; - - &.lg { - font-size: 17px; - } - } - } -} - .content-container { width: 97%; float: right; diff --git a/src/app/post/components/post-list/post-list.component.ts b/src/app/post/components/post-list/post-list.component.ts index 92293f28b..c33a0988b 100644 --- a/src/app/post/components/post-list/post-list.component.ts +++ b/src/app/post/components/post-list/post-list.component.ts @@ -64,7 +64,7 @@ export class PostListComponent implements OnInit { */ public fillArticles(news: PostWithMeta): void { this.setNews(news); - news.meta.pagination.pages > news.meta.pagination.page ? (this.isLastPage = false) : (this.isLastPage = true); + this.isLastPage = news.meta.pagination.page >= news.meta.pagination.pages; const headLineTag = this.allPosts.filter((post: Post) => post.tags.some((tag) => tag && tag.slug === TagEnum.aLaUne) ); diff --git a/src/app/shared/components/checkbox-form/checkbox-form.component.ts b/src/app/shared/components/checkbox-form/checkbox-form.component.ts index 33fbfb6f6..81f6046b0 100644 --- a/src/app/shared/components/checkbox-form/checkbox-form.component.ts +++ b/src/app/shared/components/checkbox-form/checkbox-form.component.ts @@ -11,7 +11,6 @@ export class CheckboxFormComponent { @Input() public iconSvg: string; @Input() public iconType: string; @Output() checkEvent: EventEmitter<boolean> = new EventEmitter<boolean>(); - constructor() {} public clicked(): void { this.isChecked = !this.isChecked; diff --git a/src/app/shared/components/data-share-consent/data-share-consent.component.ts b/src/app/shared/components/data-share-consent/data-share-consent.component.ts index 63c81a71c..d23d53b4a 100644 --- a/src/app/shared/components/data-share-consent/data-share-consent.component.ts +++ b/src/app/shared/components/data-share-consent/data-share-consent.component.ts @@ -78,7 +78,7 @@ export class DataShareConsentComponent implements OnInit { this.submitted = true; this.loading = true; for (let structure of this.dataConsentPendingStructures) { - this.structureService.editStructure(structure).subscribe((s: Structure) => {}); + this.structureService.editStructure(structure).subscribe((_s: Structure) => {}); } this.loading = false; this.openned = false; diff --git a/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts b/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts index 3c8132aaf..c97831519 100644 --- a/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts +++ b/src/app/shared/components/hour-picker/copy-paste/copy-paste.component.ts @@ -12,12 +12,6 @@ export class CopyPasteComponent { @Output() copyEvent = new EventEmitter<any>(); @Output() cancelEvent = new EventEmitter<any>(); @Output() pasteEvent = new EventEmitter<any>(); - constructor() { - var myarray = [80, 3, 9, 34, 23, 5, 1]; - - myarray.sort(); - console.log(myarray); - } public copy(): void { this.copyEvent.emit(this.day); diff --git a/src/app/shared/components/training-type-picker/training-type-picker.component.scss b/src/app/shared/components/training-type-picker/training-type-picker.component.scss index 268d65ca4..e394db9f9 100644 --- a/src/app/shared/components/training-type-picker/training-type-picker.component.scss +++ b/src/app/shared/components/training-type-picker/training-type-picker.component.scss @@ -8,8 +8,9 @@ button { outline: none; border: none; } + .tags { - padding: 15px; + padding: 8px; width: calc(100% + 2px); margin-left: -16px; height: 100%; @@ -23,7 +24,19 @@ button { height: 40px; padding: 0 28px; cursor: pointer; + outline: none; + border: none; @include lato-bold-14; + &.selectedChoice { + background: $green-1 !important; + color: $white; + } + svg { + width: 20px; + height: 10px; + margin-right: 4px; + stroke: $grey-8; + } } } .boutonSection { @@ -133,29 +146,3 @@ button { } } } - -.tags { - padding: 8px; - button { - background: $grey-8; - border-radius: 20px; - margin: 4px; - max-width: 100%; - height: 40px; - padding: 0 13px; - @include lato-bold-14; - outline: none; - border: none; - cursor: pointer; - &.selectedChoice { - background: $green-1 !important; - color: $white; - } - } - svg { - width: 20px; - height: 10px; - margin-right: 4px; - stroke: $grey-8; - } -} -- GitLab