From b761be8a61baba74b4e3d5ea9a5428ebea571a6f Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Fri, 11 Dec 2020 11:28:01 +0100
Subject: [PATCH] fix: sonar issues. Unused imports, empty block ...

---
 src/app/home/home.component.ts                 |  4 +---
 src/app/map/components/map.component.ts        | 17 +----------------
 src/app/map/services/map.service.spec.ts       |  1 -
 src/app/services/geojson.service.spec.ts       |  1 -
 src/app/services/geojson.service.ts            |  3 +--
 .../services/structure-list.service.spec.ts    |  2 +-
 .../logo-card/logo-card.component.ts           |  9 ++++-----
 .../components/search/search.component.spec.ts |  2 +-
 .../components/search/search.component.ts      |  2 +-
 .../structure-list.component.spec.ts           |  1 -
 .../structure-list/structure-list.component.ts |  4 +---
 src/test.ts                                    | 18 ++++++++----------
 12 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts
index 8ccaba5fc..34e9906b3 100644
--- a/src/app/home/home.component.ts
+++ b/src/app/home/home.component.ts
@@ -1,6 +1,4 @@
 import { Component, OnInit } from '@angular/core';
-import { Observable } from 'rxjs';
-import { mergeMap } from 'rxjs/operators';
 const { DateTime } = require('luxon');
 import * as _ from 'lodash';
 
@@ -98,7 +96,7 @@ export class HomeComponent implements OnInit {
    * @param value string
    */
   private isLocationRequest(value: string): boolean {
-    const regex = /^\d+\s[A-z]+\s[A-z]+/g;
+    const regex = /^\d+\s[A-z]+\s[A-z]+/g; //NOSONAR
     if (value.match(regex)) {
       return true;
     }
diff --git a/src/app/map/components/map.component.ts b/src/app/map/components/map.component.ts
index 348453ad2..52e310348 100644
--- a/src/app/map/components/map.component.ts
+++ b/src/app/map/components/map.component.ts
@@ -8,23 +8,8 @@ import {
   SimpleChanges,
   ViewChild,
 } from '@angular/core';
-import {
-  latLng,
-  MapOptions,
-  tileLayer,
-  Map,
-  CRS,
-  TileLayer,
-  LatLngBounds,
-  latLngBounds,
-  Marker,
-  layerGroup,
-  polyline,
-} from 'leaflet';
-import { Observable } from 'rxjs';
-import { mergeMap } from 'rxjs/operators';
+import { latLng, MapOptions, tileLayer, Map, CRS, TileLayer, LatLngBounds, latLngBounds, layerGroup } from 'leaflet';
 import { Structure } from '../../models/structure.model';
-import { GeoJson } from '../models/geojson.model';
 import { GeojsonService } from '../../services/geojson.service';
 import { MapService } from '../services/map.service';
 import { NgxLeafletLocateComponent } from '@runette/ngx-leaflet-locate';
diff --git a/src/app/map/services/map.service.spec.ts b/src/app/map/services/map.service.spec.ts
index eb3b55054..ca4b202d0 100644
--- a/src/app/map/services/map.service.spec.ts
+++ b/src/app/map/services/map.service.spec.ts
@@ -1,5 +1,4 @@
 import { TestBed } from '@angular/core/testing';
-import { Map } from 'leaflet';
 
 import { MapService } from './map.service';
 
diff --git a/src/app/services/geojson.service.spec.ts b/src/app/services/geojson.service.spec.ts
index 71045a64d..8610cc4fe 100644
--- a/src/app/services/geojson.service.spec.ts
+++ b/src/app/services/geojson.service.spec.ts
@@ -1,5 +1,4 @@
 import { TestBed } from '@angular/core/testing';
-import { Address } from '../models/address.model';
 
 import { GeojsonService } from './geojson.service';
 import { HttpClientModule } from '@angular/common/http';
diff --git a/src/app/services/geojson.service.ts b/src/app/services/geojson.service.ts
index 5f15ae6d8..b48ce0da4 100644
--- a/src/app/services/geojson.service.ts
+++ b/src/app/services/geojson.service.ts
@@ -1,8 +1,7 @@
-import { HttpClient, HttpHeaders } from '@angular/common/http';
+import { HttpClient } from '@angular/common/http';
 import { Injectable } from '@angular/core';
 import { Observable } from 'rxjs';
 import { map } from 'rxjs/operators';
-import { Address } from '../models/address.model';
 import { GeoJson } from '../map/models/geojson.model';
 import * as _ from 'lodash';
 
diff --git a/src/app/services/structure-list.service.spec.ts b/src/app/services/structure-list.service.spec.ts
index 5a1b05cc4..fa4b0f4eb 100644
--- a/src/app/services/structure-list.service.spec.ts
+++ b/src/app/services/structure-list.service.spec.ts
@@ -1,5 +1,5 @@
 import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { inject, TestBed } from '@angular/core/testing';
+import { TestBed } from '@angular/core/testing';
 import { Day } from '../models/day.model';
 import { Structure } from '../models/structure.model';
 import { Time } from '../models/time.model';
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 ed7ddbcf3..874d23679 100644
--- a/src/app/shared/components/logo-card/logo-card.component.ts
+++ b/src/app/shared/components/logo-card/logo-card.component.ts
@@ -19,11 +19,10 @@ export class LogoCardComponent implements OnInit {
 
   // Get the custom or default name from a demarche.
   public getName(demarche: string): string {
-    switch (demarche) {
-      case Demarches.caf:
-        return 'Caf';
-      default:
-        return demarche;
+    if (demarche === Demarches.caf) {
+      return 'Caf';
+    } else {
+      return demarche;
     }
   }
   public getLogoKey(demarche: string): string {
diff --git a/src/app/structure-list/components/search/search.component.spec.ts b/src/app/structure-list/components/search/search.component.spec.ts
index be7013937..8753300fe 100644
--- a/src/app/structure-list/components/search/search.component.spec.ts
+++ b/src/app/structure-list/components/search/search.component.spec.ts
@@ -104,7 +104,7 @@ describe('SearchComponent', () => {
     const checkedModules: Module[] = [{ id: evt.target.value, text: categ, count: 0 }];
     component.checkedModulesFilter = checkedModules;
     component.numericPassCheck(evt, categ);
-    const expectArray: Module[] = [new Module(evt.target.value, categ)];
+    new Module(evt.target.value, categ);
     expect(component.checkedModulesFilter.length).toEqual(0);
     expect(component.numberMoreFiltersChecked).toEqual(0);
   });
diff --git a/src/app/structure-list/components/search/search.component.ts b/src/app/structure-list/components/search/search.component.ts
index 485ad2e50..5d3aa934e 100644
--- a/src/app/structure-list/components/search/search.component.ts
+++ b/src/app/structure-list/components/search/search.component.ts
@@ -1,4 +1,4 @@
-import { Component, EventEmitter, OnInit, Output, Type } from '@angular/core';
+import { Component, EventEmitter, OnInit, Output } from '@angular/core';
 import { FormBuilder, FormGroup } from '@angular/forms';
 import { forkJoin } from 'rxjs';
 import { GeoJson } from '../../../map/models/geojson.model';
diff --git a/src/app/structure-list/structure-list.component.spec.ts b/src/app/structure-list/structure-list.component.spec.ts
index bffca76c3..86f83cd75 100644
--- a/src/app/structure-list/structure-list.component.spec.ts
+++ b/src/app/structure-list/structure-list.component.spec.ts
@@ -1,5 +1,4 @@
 import { ComponentFixture, TestBed } from '@angular/core/testing';
-import { StyleUtils } from '@angular/flex-layout';
 import { OpeningDay } from '../models/openingDay.model';
 import { Structure } from '../models/structure.model';
 import { Filter } from './models/filter.model';
diff --git a/src/app/structure-list/structure-list.component.ts b/src/app/structure-list/structure-list.component.ts
index 19a694e2c..fedd27acf 100644
--- a/src/app/structure-list/structure-list.component.ts
+++ b/src/app/structure-list/structure-list.component.ts
@@ -1,4 +1,4 @@
-import { Component, EventEmitter, Input, OnInit, Output, OnChanges, SimpleChanges } from '@angular/core';
+import { Component, EventEmitter, Input, Output, OnChanges, SimpleChanges } from '@angular/core';
 import { Filter } from './models/filter.model';
 import { Structure } from '../models/structure.model';
 import { GeoJson } from '../map/models/geojson.model';
@@ -64,8 +64,6 @@ export class StructureListComponent implements OnChanges {
   }
 
   public onScrollDown(event): void {
-    if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight - 100) {
-    }
     if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight - 50) {
       this.loadMoreStructures();
     }
diff --git a/src/test.ts b/src/test.ts
index 50193eb0f..f5a348084 100644
--- a/src/test.ts
+++ b/src/test.ts
@@ -2,24 +2,22 @@
 
 import 'zone.js/dist/zone-testing';
 import { getTestBed } from '@angular/core/testing';
-import {
-  BrowserDynamicTestingModule,
-  platformBrowserDynamicTesting
-} from '@angular/platform-browser-dynamic/testing';
+import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
 
 declare const require: {
-  context(path: string, deep?: boolean, filter?: RegExp): {
+  context(
+    path: string,
+    deep?: boolean,
+    filter?: RegExp
+  ): {
     keys(): string[];
     <T>(id: string): T;
   };
 };
 
 // First, initialize the Angular testing environment.
-getTestBed().initTestEnvironment(
-  BrowserDynamicTestingModule,
-  platformBrowserDynamicTesting()
-);
+getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
 // Then we find all the tests.
 const context = require.context('./', true, /\.spec\.ts$/);
 // And load the modules.
-context.keys().map(context);
+context.keys().map(context); //NOSONAR
-- 
GitLab