From f7f9b9c2a77cfe3e8eb8023639e7af25f5af31ad Mon Sep 17 00:00:00 2001 From: phantomjinx Date: Fri, 25 May 2018 14:11:20 +0100 Subject: [PATCH] Turns off unnecessary lint rules and fixes remaining lint errors --- ngapp/src/app/core/api.service.ts | 22 +++++---- .../dataservices/dataservices.component.ts | 2 - .../odata-control/odata-constants.ts | 11 ++++- .../odata-control/odata-control.component.ts | 23 ++++----- .../odata-control/odata-where.model.ts | 4 +- .../dataservices/odata-control/odata.model.ts | 47 ++++++++++--------- .../dataservices/shared/dataservice.model.ts | 2 +- .../shared/dataservice.service.ts | 6 +-- .../dataservices/shared/virt-route.model.ts | 2 +- .../shared/virtualization.model.ts | 7 ++- .../confirm-dialog.component.ts | 2 +- ngapp/tslint.json | 28 ++++------- 12 files changed, 78 insertions(+), 78 deletions(-) diff --git a/ngapp/src/app/core/api.service.ts b/ngapp/src/app/core/api.service.ts index 02530c17..7c0849f3 100644 --- a/ngapp/src/app/core/api.service.ts +++ b/ngapp/src/app/core/api.service.ts @@ -63,7 +63,7 @@ export abstract class ApiService { public isXML(xml: string): boolean { try { const parser = new X2JS(); - const xmlDoc = parser.xml2js(xml); //is valid XML + const xmlDoc = parser.xml2js(xml); // is valid XML return xmlDoc != null; } catch (err) { // was not XML @@ -74,20 +74,24 @@ export abstract class ApiService { public tryXMLParse(xml: string): any { try { const parser = new X2JS(); - const xmlDoc = parser.xml2js(xml); //is valid XML + const xmlDoc = parser.xml2js(xml); // is valid XML return xmlDoc; - } catch (err) {} + } catch (err) { + // Do nothing + } return null; } public tryNumberParse(jsonString: string): number { try { - var n = parseInt(jsonString); + const n = parseInt(jsonString, 10); if (n && typeof n === "number") { return n; } - } catch (e) {} + } catch (e) { + // Do nothing + } return null; } @@ -96,9 +100,9 @@ export abstract class ApiService { * Try to parse the given string and if parseable * then return the object */ - public tryJsonParse (jsonString: string): any { + public tryJsonParse(jsonString: string): any { try { - var o = JSON.parse(jsonString); + const o = JSON.parse(jsonString); // Handle non-exception-throwing cases: // Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking, @@ -107,7 +111,9 @@ export abstract class ApiService { if (o && typeof o === "object") { return o; } - } catch (e) {} + } catch (e) { + // Do nothing + } return null; } diff --git a/ngapp/src/app/dataservices/dataservices.component.ts b/ngapp/src/app/dataservices/dataservices.component.ts index 844137f2..71b43f99 100644 --- a/ngapp/src/app/dataservices/dataservices.component.ts +++ b/ngapp/src/app/dataservices/dataservices.component.ts @@ -824,6 +824,4 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn private setOdataServiceName(svcName): void { this.odataSvcName = svcName; } - - } diff --git a/ngapp/src/app/dataservices/odata-control/odata-constants.ts b/ngapp/src/app/dataservices/odata-control/odata-constants.ts index 4ba0196a..e47e542b 100644 --- a/ngapp/src/app/dataservices/odata-control/odata-constants.ts +++ b/ngapp/src/app/dataservices/odata-control/odata-constants.ts @@ -1,3 +1,10 @@ +/* tslint:disable:max-line-length */ + +/* + * TODO + * This file should be ported to a proper i18n translation module + */ + /** * @license * Copyright 2017 JBoss Inc @@ -58,7 +65,7 @@ export class OdataConstants { public readonly searchErrorConsoleMsg = "Error: Failed to get value at link: "; public readonly searchErrorMsg = "Error: failed to get any results: "; public readonly whereErrorMsg = "The chosen column has a type which cannot be used in a where condition"; - public readonly metadataFetchFailure = "Failed to get the odata metadata for the published artifact." + public readonly metadataFetchFailure = "Failed to get the odata metadata for the published artifact."; public readonly help_endpointSubmit = "This URL is formed using the OData specification. It can be copied into a new browser window to return the results in xml format or append ?format=json to the URL for JSON. Click the Submit button to display the results in a formatted table."; public readonly help_select = "Choose the view from which results should be sought. Select a limit to curtail the number of results returned "; @@ -68,5 +75,5 @@ export class OdataConstants { public readonly help_format = "Choose the format of the query results."; public readonly help_resultsTable = "Use the column headers to sort the results or filter them by entering values. Results are paginated in blocks of 25 and can be scrolled through with the controls at the foot of the table."; public readonly help_resultsRaw = "The raw data as returned from the odata teiid service in json format."; - public readonly help_sqlSearch = "Use the Teiid dialect of SQL to construct a query that interrogates the data service for data results. Use the record limit to limit the number of results returned. Set the starting record index to fetch a subset of results starting at the given row index."; + public readonly help_sqlSearch = "Use the Teiid dialect of SQL to construct a query that interrogates the data service for data results. Use the record limit to limit the number of results returned. Set the starting record index to fetch a subset of results starting at the given row index."; } diff --git a/ngapp/src/app/dataservices/odata-control/odata-control.component.ts b/ngapp/src/app/dataservices/odata-control/odata-control.component.ts index c6107b61..8d84482e 100644 --- a/ngapp/src/app/dataservices/odata-control/odata-control.component.ts +++ b/ngapp/src/app/dataservices/odata-control/odata-control.component.ts @@ -38,10 +38,9 @@ import { OdataWhere } from "@dataservices/odata-control/odata-where.model"; }) export class OdataControlComponent implements OnChanges { - @Input() dataserviceName: string; - - @ViewChild('odataResultsEditor') resultsEditor: any; + @Input() private dataserviceName: string; + @ViewChild('odataResultsEditor') private resultsEditor: any; private dataserviceService: DataserviceService; private dataservice: Dataservice; @@ -86,7 +85,7 @@ export class OdataControlComponent implements OnChanges { // // Format of the results // - public resultsType: string = "JSON"; + public resultsType = "JSON"; // // Results to show from the odata query @@ -121,7 +120,7 @@ export class OdataControlComponent implements OnChanges { .subscribe( (response) => { if (! _.isEmpty(response) && this.dataserviceService.isXML(response.value)) { - let xmlObject = this.dataserviceService.tryXMLParse(response.value); + const xmlObject = this.dataserviceService.tryXMLParse(response.value); this.odata.metadata = xmlObject; this.odata.metadataFailure = false; } else { @@ -154,8 +153,8 @@ export class OdataControlComponent implements OnChanges { return this.i18n.UrlNotAvailable; const service = this.odata.entity; - if (_.isEmpty(service) || _.isEmpty(service.name)) - return this.i18n.UrlNotAvailable; + if (_.isEmpty(service) || _.isEmpty(service.name)) + return this.i18n.UrlNotAvailable; let odataUrl = baseUrl + '/' + service.name; @@ -313,12 +312,12 @@ export class OdataControlComponent implements OnChanges { * * Remove the where condition since it may be invalid * * Check the column is queryable and if not display an error */ - public onWhereColumnSelected(where: OdataWhere) { + public onWhereColumnSelected(where: OdataWhere): void { if (! _.isEmpty(where) && ! _.isEmpty(where.condition)) delete where.condition; if (! _.isEmpty(where.column)) { - let index = _.indexOf(Odata.QUERYABLE_TYPES, where.column.type); + const index = _.indexOf(Odata.QUERYABLE_TYPES, where.column.type); if (index < 0) where.error = this.i18n.whereErrorMsg; else @@ -365,7 +364,7 @@ export class OdataControlComponent implements OnChanges { * Provides the choices to select for a where clause * depending on the type of column already selected */ - public whereConditions(where: OdataWhere) { + public whereConditions(where: OdataWhere): Array { if (_.isEmpty(where) || _.isEmpty(where.column)) return []; @@ -392,13 +391,11 @@ export class OdataControlComponent implements OnChanges { * Submit the query for evaluation */ public submitQuery(): void { - let url = this.endPointUrl; - this.searchMsg = null; this.searchMsgClasses = []; this.searchInProgress = true; - this.dataserviceService.odataGet(url) + this.dataserviceService.odataGet(this.endPointUrl) .subscribe( (response) => { this.results = null; diff --git a/ngapp/src/app/dataservices/odata-control/odata-where.model.ts b/ngapp/src/app/dataservices/odata-control/odata-where.model.ts index e5854cf1..6a652f73 100644 --- a/ngapp/src/app/dataservices/odata-control/odata-where.model.ts +++ b/ngapp/src/app/dataservices/odata-control/odata-where.model.ts @@ -26,8 +26,8 @@ import { OdataColumn } from "@dataservices/odata-control/odata-column.model"; export class OdataWhere { private _column: OdataColumn; - private _condition: string = ''; - private _value: string = ''; + private _condition = ''; + private _value = ''; public error: string = null; diff --git a/ngapp/src/app/dataservices/odata-control/odata.model.ts b/ngapp/src/app/dataservices/odata-control/odata.model.ts index e4f82680..75515ac7 100644 --- a/ngapp/src/app/dataservices/odata-control/odata.model.ts +++ b/ngapp/src/app/dataservices/odata-control/odata.model.ts @@ -67,7 +67,7 @@ export class Odata { private _metadata: any = null; - private _metadataFailure: boolean = false; + private _metadataFailure = false; private _entities: Array = []; @@ -92,7 +92,7 @@ export class Odata { * @returns collection of conditions for int types */ public intConditions(): string[] { - const conditions:Array = [ Odata.EQUALS, Odata.NOT_EQUALS, Odata.GREATER_THAN, + const conditions: Array = [ Odata.EQUALS, Odata.NOT_EQUALS, Odata.GREATER_THAN, Odata.GREATER_THAN_EQ_TO, Odata.LESS_THAN, Odata.LESS_THAN_EQ_TO, Odata.IN ]; return conditions; @@ -102,7 +102,7 @@ export class Odata { * @returns collection of conditions for string types */ public stringConditions(): string[] { - const conditions:Array = [ Odata.EQUALS, Odata.NOT_EQUALS, Odata.IN, Odata.EQUALS_CINS, Odata.NOT_EQUALS_CINS, + const conditions: Array = [ Odata.EQUALS, Odata.NOT_EQUALS, Odata.IN, Odata.EQUALS_CINS, Odata.NOT_EQUALS_CINS, Odata.STARTS_WITH, Odata.NO_STARTS_WITH, Odata.ENDS_WITH, Odata.NO_ENDS_WITH, Odata.CONTAINS, Odata.LENGTH_EQ ]; return conditions; @@ -112,7 +112,7 @@ export class Odata { * @returns collection of conditions for date types */ public dateConditions(): string[] { - const conditions:Array = [ Odata.EQUALS, Odata.BEFORE_DATE, Odata.AFTER_DATE, Odata.BEFORE_EQ, Odata.AFTER_EQ ]; + const conditions: Array = [ Odata.EQUALS, Odata.BEFORE_DATE, Odata.AFTER_DATE, Odata.BEFORE_EQ, Odata.AFTER_EQ ]; return conditions; } @@ -120,7 +120,7 @@ export class Odata { * @returns collection of conditions for boolean types */ public booleanConditions(): string[] { - const conditions:Array = [ Odata.EQUALS, Odata.NOT_EQUALS ]; + const conditions: Array = [ Odata.EQUALS, Odata.NOT_EQUALS ]; return conditions; } @@ -142,14 +142,14 @@ export class Odata { const columns = entity.Property; if (_.isArray(columns)) { - for (let column of columns) { - let odataColumn = new OdataColumn(); + for (const column of columns) { + const odataColumn = new OdataColumn(); odataColumn.name = column._Name; odataColumn.type = column._Type.replace('Edm.', ''); odataColumns.push(odataColumn); } } else if (_.isObject(columns)) { - let singleColumn = new OdataColumn(); + const singleColumn = new OdataColumn(); singleColumn.name = columns._Name; singleColumn.type = columns._Type.replace('Edm.', ''); odataColumns = [singleColumn]; @@ -181,14 +181,14 @@ export class Odata { const entityTypes = metadata.Edmx.DataServices.Schema.EntityType; if (_.isArray(entityTypes)) { - for (let entityType of entityTypes) { - let entity = new OdataEntity(); + for (const entityType of entityTypes) { + const entity = new OdataEntity(); entity.name = entityType._Name; entity.columns = this.extractColumns(entityType); this._entities.push(entity); } } else if (_.isObject(entityTypes)) { - let singleEntity = new OdataEntity(); + const singleEntity = new OdataEntity(); singleEntity.name = entityTypes._Name; singleEntity.columns = this.extractColumns(entityTypes); this._entities = [singleEntity]; @@ -262,7 +262,7 @@ export class Odata { * Is this column with name selected */ public hasColumn(columnName: string): boolean { - for (let column of this.columns) { + for (const column of this.columns) { if (_.isEqual(columnName, column.name)) return true; } @@ -347,7 +347,7 @@ export class Odata { * Converts the where clauses into odata where clauses */ public convertWhere(): string { - if (this._wheres.length == 0) + if (this._wheres.length === 0) return ''; const SPACE = ' '; @@ -356,10 +356,10 @@ export class Odata { const QUOTE = "'"; const COMMA = ','; - let prefix = '$filter='; + const prefix = '$filter='; let clauses = ''; - for (var i = 0; i < this._wheres.length; ++i) { + for (let i = 0; i < this._wheres.length; ++i) { const where = this._wheres[i]; const column: OdataColumn = where.column; const condition: string = where.condition; @@ -391,13 +391,15 @@ export class Odata { clause = 'tolower' + OBKT + column + CBKT + SPACE + 'eq' + SPACE + 'tolower' + OBKT + QUOTE + value + QUOTE + CBKT; - } else if (condition === Odata.NOT_EQUALS_CINS) { + } + else if (condition === Odata.NOT_EQUALS_CINS) { // // tolower(Description) ne tolower('value') // clause = 'tolower' + OBKT + column + CBKT + SPACE + 'ne' + SPACE + 'tolower' + OBKT + QUOTE + value + QUOTE + CBKT; - } else if (condition === Odata.STARTS_WITH) { + } + else if (condition === Odata.STARTS_WITH) { // // startswith(Description, 'value') // @@ -432,7 +434,8 @@ export class Odata { // length(Description) eq 5 // clause = 'length' + OBKT + column.name + CBKT + SPACE + 'eq' + SPACE + value; - } else if (condition === Odata.IN) { + } + else if (condition === Odata.IN) { // // in separated by ;, eg. 1;2 // becomes @@ -462,7 +465,7 @@ export class Odata { * Converts the column array into odata select clause */ public convertColumns(): string { - if (this._columns.length == 0) + if (this._columns.length === 0) return ''; // @@ -483,10 +486,10 @@ export class Odata { } /** - * Converts the order by values into odata orderby clause - */ + * Converts the order by values into odata orderby clause + */ public convertOrderBy(): string { - if (this._entity.columns.length == 0) + if (this._entity.columns.length === 0) return ''; // diff --git a/ngapp/src/app/dataservices/shared/dataservice.model.ts b/ngapp/src/app/dataservices/shared/dataservice.model.ts index 8de46706..6a1d2c1e 100644 --- a/ngapp/src/app/dataservices/shared/dataservice.model.ts +++ b/ngapp/src/app/dataservices/shared/dataservice.model.ts @@ -269,7 +269,7 @@ export class Dataservice implements Identifiable< string > { return null; } - let route: VirtRoute = this.virtualization.getOdataRoute(); + const route: VirtRoute = this.virtualization.getOdataRoute(); if (route == null) { return null; } diff --git a/ngapp/src/app/dataservices/shared/dataservice.service.ts b/ngapp/src/app/dataservices/shared/dataservice.service.ts index 8bd9ff63..5c7bd5bc 100644 --- a/ngapp/src/app/dataservices/shared/dataservice.service.ts +++ b/ngapp/src/app/dataservices/shared/dataservice.service.ts @@ -495,9 +495,9 @@ export class DataserviceService extends ApiService { .get(url, this.getAuthRequestOptions()) .map((response) => { const data = response.text(); - let jobj = this.tryJsonParse(data); + const jobj = this.tryJsonParse(data); if (_.isObject(jobj)) { - let json = JSON.stringify(jobj, null, 4); + const json = JSON.stringify(jobj, null, 4); return { value: json }; @@ -520,7 +520,7 @@ export class DataserviceService extends ApiService { }; } - let n = this.tryNumberParse(data); + const n = this.tryNumberParse(data); if (n) { return { count: n diff --git a/ngapp/src/app/dataservices/shared/virt-route.model.ts b/ngapp/src/app/dataservices/shared/virt-route.model.ts index bbf20a22..831c0d29 100644 --- a/ngapp/src/app/dataservices/shared/virt-route.model.ts +++ b/ngapp/src/app/dataservices/shared/virt-route.model.ts @@ -108,6 +108,6 @@ export class VirtRoute { * Is this an odata route */ public isOdata(): boolean { - return this.getProtocol() == VirtRoute.ODATA_PROTOCOL; + return this.getProtocol() === VirtRoute.ODATA_PROTOCOL; } } diff --git a/ngapp/src/app/dataservices/shared/virtualization.model.ts b/ngapp/src/app/dataservices/shared/virtualization.model.ts index 4a94b5e5..19036c56 100644 --- a/ngapp/src/app/dataservices/shared/virtualization.model.ts +++ b/ngapp/src/app/dataservices/shared/virtualization.model.ts @@ -127,10 +127,9 @@ export class Virtualization { Object.assign(this, values); if (values['routes']) { - let routes = values['routes']; - for (let i = 0; i < routes.length; ++i) { - let route = routes[i]; - let virtRoute = VirtRoute.create(route); + const routes = values['routes']; + for (const route of routes) { + const virtRoute = VirtRoute.create(route); if (!this.virtRoutes) { this.virtRoutes = []; } diff --git a/ngapp/src/app/shared/confirm-dialog/confirm-dialog.component.ts b/ngapp/src/app/shared/confirm-dialog/confirm-dialog.component.ts index 325421b9..29b4253c 100644 --- a/ngapp/src/app/shared/confirm-dialog/confirm-dialog.component.ts +++ b/ngapp/src/app/shared/confirm-dialog/confirm-dialog.component.ts @@ -28,7 +28,7 @@ export class ConfirmDialogComponent implements OnInit { @Output() public confirmAction = new EventEmitter(); - public title = "Title" + public title = "Title"; public bodyContent = "Confirmation Message"; public cancelButtonText = "Cancel"; public confirmButtonText = "Confirm"; diff --git a/ngapp/tslint.json b/ngapp/tslint.json index b9fedaaa..a6859687 100644 --- a/ngapp/tslint.json +++ b/ngapp/tslint.json @@ -6,13 +6,15 @@ "node_modules/codelyzer" ], "rules": { + "adjacent-overload-signatures": false, "align": [ true, "members", "parameters", "statements" ], - "angular-whitespace": [true, "check-interpolation"], + "angular-whitespace": false, + "array-type": false, "arrow-return-shorthand": true, "callable-types": true, "class-name": true, @@ -21,13 +23,8 @@ "check-space" ], "component-class-suffix": true, - "component-selector": [ - true, - "element", - "app", - "kebab-case" - ], - "curly": true, + "component-selector": false, + "curly": false, "deprecation": true, "directive-class-suffix": true, "directive-selector": [ @@ -45,8 +42,7 @@ "import-spacing": true, "indent": [ true, - "spaces", - 4 + "spaces" ], "interface-name": false, "interface-over-type-literal": true, @@ -57,10 +53,10 @@ true, 140 ], + "max-line-length": false, "member-access": true, "member-ordering": [ true, - "public-before-private", "static-before-instance", "variables-before-functions" ], @@ -109,7 +105,6 @@ true, "check-open-brace", "check-catch", - "check-else", "check-whitespace" ], "one-variable-per-declaration": [ @@ -117,16 +112,11 @@ "ignore-for-loop" ], "ordered-imports": [ - true, - { - "import-sources-order": "case-insensitive", - "named-imports-order": "case-insensitive" - } + false ], "prefer-const": true, "quotemark": [ - true, - "double" + false ], "radix": true, "restrict-plus-operands": false,