From 4294ee378439c1213d3c170a2464bdfd6ecb351c Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Tue, 30 Jun 2020 16:02:58 +0200
Subject: [PATCH] Lint code

---
 src/app/app.component.ts                               |  7 +++----
 src/app/app.module.ts                                  |  2 +-
 .../calculator-list/calculator-list.component.ts       |  2 +-
 .../dialog-edit-param-values.component.ts              |  5 ++++-
 .../dialog-load-session.component.ts                   |  2 +-
 .../dialog-new-pb-cloison.component.ts                 | 10 +++++-----
 .../components/jet-results/jet-results.component.ts    |  2 +-
 src/app/formulaire/elements/select-field.ts            |  2 --
 src/app/services/app-setup.service.ts                  |  2 +-
 src/app/services/formulaire.service.ts                 |  4 ++--
 10 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 2a71b16a8..4c4f43902 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -7,7 +7,6 @@ import { CdkDragDrop, moveItemInArray } from "@angular/cdk/drag-drop";
 
 import { Observer, jalhydDateRev, jalhydVersion, CalculatorType, Session } from "jalhyd";
 
-import { environment } from "../environments/environment";
 import { I18nService } from "./services/internationalisation.service";
 import { ErrorService } from "./services/error.service";
 import { FormulaireService } from "./services/formulaire.service";
@@ -663,7 +662,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
     const existingNotes = Session.getInstance().documentation;
     // load
     try {
-      const data = await this.formulaireService.loadSession(f, info)
+      const data = await this.formulaireService.loadSession(f, info);
       if (data.hasErrors) {
         this.notificationsService.notify(this.intlService.localizeText("ERROR_PROBLEM_LOADING_SESSION"), 3500);
       } else {
@@ -684,7 +683,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
           }
         }
       }
-    } catch(err) {
+    } catch (err) {
       this.notificationsService.notify(this.intlService.localizeText("ERROR_LOADING_SESSION"), 3500);
       console.error("error loading session - ", err);
       // rollback to ensure session is clean
@@ -869,7 +868,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
   @HostListener("window:beforeunload", [ "$event" ]) confirmExit($event) {
     if (
       this.appSetupService.warnBeforeTabClose
-      && environment.production // otherwise prevents dev server to reload app after recompiling
+      && ! isDevMode() // otherwise prevents dev server to reload app after recompiling
     ) {
       // affecter une valeur différente de null provoque l'affichage d'un dialogue de confirmation, mais le texte n'est pas affiché
       $event.returnValue = "Your data will be lost !";
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index e7d78e13b..6cade944f 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -85,7 +85,7 @@ import { ParamLinkComponent } from "./components/param-link/param-link.component
 import { SelectModelFieldLineComponent } from "./components/select-model-field-line/select-model-field-line.component";
 import { PabProfileChartComponent } from "./components/pab-profile-chart/pab-profile-chart.component";
 import { PabTableComponent } from "./components/pab-table/pab-table.component";
-import { PbSchemaComponent } from './components/pb-schema/pb-schema.component';
+import { PbSchemaComponent } from "./components/pb-schema/pb-schema.component";
 import { VariableResultsSelectorComponent } from "./components/variable-results-selector/variable-results-selector.component";
 import { QuicknavComponent } from "./components/quicknav/quicknav.component";
 import { ModulesDiagramComponent } from "./components/modules-diagram/modules-diagram.component";
diff --git a/src/app/components/calculator-list/calculator-list.component.ts b/src/app/components/calculator-list/calculator-list.component.ts
index 5f47f388c..81b255b73 100644
--- a/src/app/components/calculator-list/calculator-list.component.ts
+++ b/src/app/components/calculator-list/calculator-list.component.ts
@@ -205,7 +205,7 @@ export class CalculatorListComponent implements OnInit {
             const d = await this.httpService.httpGetBlobRequestPromise(realPath);
             const f: any = new Blob([d], { type: "application/json" });
             this.appComponent.loadSessionFile(f);
-        } catch(e) {
+        } catch (e) {
             console.error("could not load session file", e);
         }
     }
diff --git a/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts b/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts
index 7da1e632c..3c419f000 100644
--- a/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts
+++ b/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts
@@ -215,7 +215,10 @@ export class DialogEditParamValuesComponent implements OnInit {
                 if (this.param.paramDefinition.step === 0) {
                     return 0;
                 } else {
-                    return Math.max(0, Math.ceil((this.param.paramDefinition.max - this.param.paramDefinition.min) / this.param.paramDefinition.step) + 1);
+                    return Math.max(
+                        0,
+                        Math.ceil((this.param.paramDefinition.max - this.param.paramDefinition.min) / this.param.paramDefinition.step) + 1
+                    );
                 }
             } catch (e) {
                 // min > max or something, silent fail
diff --git a/src/app/components/dialog-load-session/dialog-load-session.component.ts b/src/app/components/dialog-load-session/dialog-load-session.component.ts
index 291de8698..3f1af0f0d 100644
--- a/src/app/components/dialog-load-session/dialog-load-session.component.ts
+++ b/src/app/components/dialog-load-session/dialog-load-session.component.ts
@@ -161,7 +161,7 @@ export class DialogLoadSessionComponent {
             }
           }
           this.loadingComplete = true;
-        } catch(err) {
+        } catch (err) {
           console.error(err);
           this.loadingError = true;
         }
diff --git a/src/app/components/dialog-new-pb-cloison/dialog-new-pb-cloison.component.ts b/src/app/components/dialog-new-pb-cloison/dialog-new-pb-cloison.component.ts
index 7798238d6..a249ca814 100644
--- a/src/app/components/dialog-new-pb-cloison/dialog-new-pb-cloison.component.ts
+++ b/src/app/components/dialog-new-pb-cloison/dialog-new-pb-cloison.component.ts
@@ -33,7 +33,7 @@ export class DialogNewPbCloisonComponent implements OnInit {
 
     public get availableUpstreamIndexes(): number[] {
         // add river upstream as "0"
-        let ab: number[] = [ 0 ];
+        const ab: number[] = [ 0 ];
         for (let i = 0; i < this.availableBasins.length; i++) {
             ab.push(i + 1);
         }
@@ -41,7 +41,7 @@ export class DialogNewPbCloisonComponent implements OnInit {
     }
 
     public get availableDownstreamIndexes(): number[] {
-        let ab: number[] = [ ];
+        const ab: number[] = [ ];
         for (let i = 0; i < this.availableBasins.length; i++) {
             ab.push(i + 1);
         }
@@ -58,9 +58,9 @@ export class DialogNewPbCloisonComponent implements OnInit {
      */
     public basinIsSelectable(index: number, downstream: boolean = false): boolean {
         if (downstream) {
-            return (this.upstreamIndex === 0 || index > this.upstreamIndex)
+            return (this.upstreamIndex === 0 || index > this.upstreamIndex);
         } else {
-            return (this.downstreamIndex === 0 || index < this.downstreamIndex)
+            return (this.downstreamIndex === 0 || index < this.downstreamIndex);
         }
     }
 
@@ -117,7 +117,7 @@ export class DialogNewPbCloisonComponent implements OnInit {
     public get uitextValidate() {
       return this.i18nService.localizeText("INFO_OPTION_VALIDATE");
     }
-  
+
     public get uitextCancel() {
       return this.i18nService.localizeText("INFO_OPTION_CANCEL");
     }
diff --git a/src/app/components/jet-results/jet-results.component.ts b/src/app/components/jet-results/jet-results.component.ts
index 50d8a1a1d..9d991de25 100644
--- a/src/app/components/jet-results/jet-results.component.ts
+++ b/src/app/components/jet-results/jet-results.component.ts
@@ -28,7 +28,7 @@ export class JetResultsComponent extends FixedVarResultsComponent {
         return this.hasResults && (
             this._fixedResults && this._fixedResults.result && this._fixedResults.result.sourceNub.result.ok
             ||
-            this._varResults&& this._varResults.result && this._varResults.result.sourceNub.result.ok
+            this._varResults && this._varResults.result && this._varResults.result.sourceNub.result.ok
         );
     }
 
diff --git a/src/app/formulaire/elements/select-field.ts b/src/app/formulaire/elements/select-field.ts
index 468dca562..79d8e9cd9 100644
--- a/src/app/formulaire/elements/select-field.ts
+++ b/src/app/formulaire/elements/select-field.ts
@@ -197,8 +197,6 @@ export class SelectField extends Field {
                 const loiDebit = child.properties.getPropValue("loiDebit");
                 const stCode = StructureProperties.findCompatibleStructure(loiDebit, nub as ParallelStructure);
                 const stName = StructureType[stCode];
-                // console.log(`__device_loi_debit__ : child=${child.constructor.name}, loiDebit=${loiDebit}, stCode=${stCode}, stName=${stName}`);
-                // console.log("(child.properties)", child.properties.props);
                 for (const ld of la[stName]) {
                     const e: SelectEntry = new SelectEntry(this._entriesBaseId + LoiDebit[ld], ld);
                     this.addEntry(e);
diff --git a/src/app/services/app-setup.service.ts b/src/app/services/app-setup.service.ts
index 7a2d2a30b..e31d1e37b 100644
--- a/src/app/services/app-setup.service.ts
+++ b/src/app/services/app-setup.service.ts
@@ -115,7 +115,7 @@ export class ApplicationSetupService extends Observable {
      * Restore configuration values
      */
     public async restoreDefaultValues(): Promise<any> {
-        await this.readValuesFromConfig()
+        await this.readValuesFromConfig();
         // notify I18nService
         this.notifyObservers({
             action: "languagePreferenceChanged",
diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts
index 3cb284a73..6650d9ff0 100644
--- a/src/app/services/formulaire.service.ts
+++ b/src/app/services/formulaire.service.ts
@@ -96,7 +96,7 @@ export class FormulaireService extends Observable {
         try {
             const localisation = await this.loadLocalisationForLang(calc, lang);
             return localisation as StringMap;
-        } catch(e) {
+        } catch (e) {
             console.error(e);
             // try default lang (the one in the config file) ?
             const fallbackLang = this.appSetupService.fallbackLanguage;
@@ -125,7 +125,7 @@ export class FormulaireService extends Observable {
                 this._languageCache[ct] = this._languageCache[ct] || {};
                 this._languageCache[ct][lang] = localisation;
                 return localisation as StringMap;
-            } catch(e) {
+            } catch (e) {
                 throw new Error(`LOCALISATION_FILE_NOT_FOUND "${f}"`);
             }
         }
-- 
GitLab