From 810a193792e38024a81602dcce5d3e318b847592 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Thu, 12 May 2022 11:26:36 +0200
Subject: [PATCH 1/4] fix: add sonar again

---
 .gitlab-ci.yml | 72 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 51 insertions(+), 21 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 11f699b5d..9574588f9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,5 @@
 stages:
-  - sonar-analysis
+  - quality
   - build
   - deploy
 
@@ -102,26 +102,56 @@ deploy_rec:
   environment:
     name: rec
     url: https://resin-rec.grandlyon.com
-# code_analysis:
-#   image: skilldlabs/sonar-scanner:3.4.0
-#   services:
-#     - docker:18.09-dind
-#   stage: sonar-analysis
-#   only:
-#     - dev
-#   before_script:
-#     - export NODE_PATH=$NODE_PATH:`npm root -g`
-#     - npm install -g typescript
-#   script:
-#     - >
-#       sonar-scanner
-#       -Dsonar.projectName=${SONAR_PROJECT_KEY}
-#       -Dsonar.projectVersion=1.0
-#       -Dsonar.sourceEncoding=UTF-8
-#       -Dsonar.projectBaseDir=.
-#       -Dsonar.host.url=${SONAR_URL}
-#       -Dsonar.projectKey=${SONAR_PROJECT_KEY}
-#       -Dsonar.login=${SONAR_TOKEN}
+
+sonarqube:
+  stage: quality
+  only:
+    - dev
+  image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/sonarsource/sonar-scanner-cli:4
+  variables:
+    SONAR_USER_HOME: '${CI_PROJECT_DIR}/.sonar' # Defines the location of the analysis task cache
+    GIT_DEPTH: '0' # T
+  cache:
+    key: '${CI_JOB_NAME}'
+    paths:
+      - .sonar/cache
+  script:
+    - >
+      sonar-scanner
+      -Dsonar.projectName=${SONAR_PROJECT_KEY}
+      -Dsonar.projectVersion=1.0
+      -Dsonar.sourceEncoding=UTF-8
+      -Dsonar.projectBaseDir=.
+      -Dsonar.host.url=${SONAR_URL}
+      -Dsonar.projectKey=${SONAR_PROJECT_KEY}
+      -Dsonar.login=${SONAR_TOKEN}
+      -Dsonar.cpd.exclusions=tests/**,src/**/*.spec.ts*
+      -Dsonar.qualitygate.wait=true
+
+sonarqube-mr:
+  stage: quality
+  only:
+    - merge_requests
+  image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/sonarsource/sonar-scanner-cli:4
+  variables:
+    SONAR_USER_HOME: '${CI_PROJECT_DIR}/.sonar' # Defines the location of the analysis task cache
+    GIT_DEPTH: '0' # T
+  cache:
+    key: '${CI_JOB_NAME}'
+    paths:
+      - .sonar/cache
+  script:
+    - >
+      sonar-scanner
+      -Dsonar.projectName=${SONAR_PROJECT_KEY}
+      -Dsonar.projectVersion=1.0
+      -Dsonar.sourceEncoding=UTF-8
+      -Dsonar.projectBaseDir=.
+      -Dsonar.host.url=${SONAR_URL}
+      -Dsonar.projectKey=${SONAR_PROJECT_KEY}
+      -Dsonar.login=${SONAR_MR_TOKEN}
+      -Dsonar.cpd.exclusions=tests/**,src/**/*.spec.ts*
+      -Dsonar.qualitygate.wait=true
 
 # mr:
 #   variables:
-- 
GitLab


From 579991e744bd4e44446675c76f995b1e4726b1fb Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Thu, 12 May 2022 11:30:22 +0200
Subject: [PATCH 2/4] fix: add build branch to pipeline

---
 .gitlab-ci.yml | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9574588f9..0f3a7115d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,6 +16,8 @@ build_branch:
     DOCKER_TLS_CERTDIR: ''
     DOCKER_HOST: tcp://docker:2375/
     DOCKER_DRIVER: overlay2
+  only:
+    - merge_requests
   image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09
   stage: build
   except:
@@ -152,16 +154,3 @@ sonarqube-mr:
       -Dsonar.login=${SONAR_MR_TOKEN}
       -Dsonar.cpd.exclusions=tests/**,src/**/*.spec.ts*
       -Dsonar.qualitygate.wait=true
-
-# mr:
-#   variables:
-#     DOCKER_TLS_CERTDIR: ''
-#     DOCKER_HOST: tcp://docker:2375/
-#     DOCKER_DRIVER: overlay2
-#   image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09
-#   stage: build
-#   only:
-#     - merge_requests
-#   script:
-#     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-#     - docker build --pull -t "$CI_REGISTRY_IMAGE:dev" --build-arg conf=dev .
-- 
GitLab


From 6f56f9c00910c31cf1a0a190c1b1ab0269919c5d Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Thu, 12 May 2022 12:18:56 +0200
Subject: [PATCH 3/4] fix: sonar bug

---
 .../manage-users/manage-users.component.ts         |  6 +++---
 .../structure-print-header.component.html          |  6 ++++++
 .../structure-list-search.component.spec.ts        | 14 ++++++--------
 3 files changed, 15 insertions(+), 11 deletions(-)

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 d4713e661..03399985c 100644
--- a/src/app/admin/components/manage-users/manage-users.component.ts
+++ b/src/app/admin/components/manage-users/manage-users.component.ts
@@ -1,8 +1,8 @@
 import { Component } from '@angular/core';
 import { User } from '../../../models/user.model';
 import { AdminService } from '../../services/admin.service';
-import { DeleteUserComponent } from './delete-user/delete-user.component';
 import { AdministredStructuresComponent } from './administred-structures/administred-structures.component';
+import { DeleteUserComponent } from './delete-user/delete-user.component';
 
 @Component({
   selector: 'app-admin-manage-users',
@@ -105,7 +105,7 @@ export class ManageUsersComponent {
   public findAttachedUsers(): void {
     this.adminService.getAttachedUsers().subscribe((users) => {
       this.attachedUsers = users;
-      this.attachedUsers.map((user) => {
+      this.attachedUsers.forEach((user) => {
         user._id = user['id'];
       });
     });
@@ -120,7 +120,7 @@ export class ManageUsersComponent {
   public findUnVerifiedUsers(): void {
     this.adminService.getUnVerifiedUsers().subscribe((users) => {
       this.unVerifiedUsers = users;
-      this.unVerifiedUsers.map((user) => {
+      this.unVerifiedUsers.forEach((user) => {
         user._id = user['id'];
       });
     });
diff --git a/src/app/form/orientation-form/component/structure-print-header/structure-print-header.component.html b/src/app/form/orientation-form/component/structure-print-header/structure-print-header.component.html
index 7c09be927..38bc6abfa 100644
--- a/src/app/form/orientation-form/component/structure-print-header/structure-print-header.component.html
+++ b/src/app/form/orientation-form/component/structure-print-header/structure-print-header.component.html
@@ -25,6 +25,12 @@
     </div>
     <div class="beneficiary">
       <div class="informationHeader">{{ 'Bénéficiaire' | uppercase }}</div>
+      <caption style="display: none">
+        Résumé du besoin de l'utilisateur pour impresion.
+      </caption>
+      <thead style="display: none">
+        <th>Résumé de besoin</th>
+      </thead>
       <!-- Name -->
       <table class="beneficiaryNeeds">
         <tr>
diff --git a/src/app/structure-list/components/structure-list-search/structure-list-search.component.spec.ts b/src/app/structure-list/components/structure-list-search/structure-list-search.component.spec.ts
index d3480a964..1cac4adfa 100644
--- a/src/app/structure-list/components/structure-list-search/structure-list-search.component.spec.ts
+++ b/src/app/structure-list/components/structure-list-search/structure-list-search.component.spec.ts
@@ -1,13 +1,13 @@
+import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
 import { ReactiveFormsModule } from '@angular/forms';
+import { of } from 'rxjs';
+import { GeoJson } from '../../../map/models/geojson.model';
+import { GeojsonService } from '../../../services/geojson.service';
+import { TypeModal } from '../../enum/typeModal.enum';
 import { Filter } from '../../models/filter.model';
-import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { StructureListSearchComponent } from './structure-list-search.component';
 import { Module } from '../../models/module.model';
-import { TypeModal } from '../../enum/typeModal.enum';
-import { GeojsonService } from '../../../services/geojson.service';
-import { GeoJson } from '../../../map/models/geojson.model';
-import { of } from 'rxjs';
+import { StructureListSearchComponent } from './structure-list-search.component';
 
 describe('StructureListSearchComponent', () => {
   let component: StructureListSearchComponent;
@@ -104,7 +104,6 @@ describe('StructureListSearchComponent', () => {
     const checkedModules: Module[] = [{ id: evt.target.value, text: categ, count: 0 }];
     component.checkedModulesFilter = checkedModules;
     component.externalCheckboxCheck(evt, categ);
-    new Module(evt.target.value, categ);
     expect(component.checkedModulesFilter.length).toEqual(0);
     expect(component.numberMoreFiltersChecked).toEqual(0);
   });
@@ -122,7 +121,6 @@ describe('StructureListSearchComponent', () => {
     const checkedModules: Module[] = [{ id: evt.target.value, text: categ, count: 0 }];
     component.checkedModulesFilter = checkedModules;
     component.externalCheckboxCheck(evt, categ);
-    new Module(evt.target.value, categ);
     expect(component.checkedModulesFilter.length).toEqual(0);
     expect(component.numberMoreFiltersChecked).toEqual(0);
   });
-- 
GitLab


From 729b5a12a371ee765447eace0e79f66ce4e65e25 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Thu, 12 May 2022 12:29:17 +0200
Subject: [PATCH 4/4] fix: sonar

---
 .../structure-print-header.component.html         | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/app/form/orientation-form/component/structure-print-header/structure-print-header.component.html b/src/app/form/orientation-form/component/structure-print-header/structure-print-header.component.html
index 38bc6abfa..2e40f7336 100644
--- a/src/app/form/orientation-form/component/structure-print-header/structure-print-header.component.html
+++ b/src/app/form/orientation-form/component/structure-print-header/structure-print-header.component.html
@@ -25,14 +25,15 @@
     </div>
     <div class="beneficiary">
       <div class="informationHeader">{{ 'Bénéficiaire' | uppercase }}</div>
-      <caption style="display: none">
-        Résumé du besoin de l'utilisateur pour impresion.
-      </caption>
-      <thead style="display: none">
-        <th>Résumé de besoin</th>
-      </thead>
-      <!-- Name -->
+
       <table class="beneficiaryNeeds">
+        <caption style="display: none">
+          Résumé du besoin de l'utilisateur pour impresion.
+        </caption>
+        <thead style="display: none">
+          <th>Résumé de besoin</th>
+        </thead>
+        <!-- Name -->
         <tr>
           <td class="informationHeader">Nom</td>
           <td class="bold">{{ beneficiaryName }}</td>
-- 
GitLab