From: Tiago Melo Date: Fri, 20 Dec 2019 12:15:34 +0000 (-0100) Subject: mgr/dashboard: Enable noImplicitReturns TS compiler option X-Git-Tag: v15.1.1~573^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=bd39fa2f3d11abbb85db97f36732b10d0855689a;p=ceph-ci.git mgr/dashboard: Enable noImplicitReturns TS compiler option Fixes: https://tracker.ceph.com/issues/43525 Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts index 464d61ed78a..45bbd7e6ede 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts @@ -197,7 +197,7 @@ export abstract class PageHelper { async clearInput(elem: ElementFinder) { const types = ['text', 'number']; if ((await elem.getTagName()) === 'input' && types.includes(await elem.getAttribute('type'))) { - await elem.sendKeys( + return await elem.sendKeys( protractor.Key.chord(protractor.Key.CONTROL, 'a'), protractor.Key.BACK_SPACE ); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts index 43e4124a190..12a8b3be7c5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts @@ -165,6 +165,8 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy { if (first && _.isUndefined(first['info'])) { return this.i18n('Unavailable gateway(s)'); } + + return undefined; } getDeleteDisableDesc(): string | undefined { @@ -178,6 +180,8 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy { if (first && first['info'] && first['info']['num_sessions']) { return this.i18n('Target has active sessions'); } + + return undefined; } prepareResponse(resp: any): any[] { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-edit-peer-modal/pool-edit-peer-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-edit-peer-modal/pool-edit-peer-modal.component.ts index aefbebae111..2181bc4a7e1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-edit-peer-modal/pool-edit-peer-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-edit-peer-modal/pool-edit-peer-modal.component.ts @@ -67,18 +67,24 @@ export class PoolEditPeerModalComponent implements OnInit { if (!control.value.match(/^[\w\-_]*$/)) { return { invalidClusterName: { value: control.value } }; } + + return undefined; } validateClientID(control: AbstractControl) { if (!control.value.match(/^(?!client\.)[\w\-_.]*$/)) { return { invalidClientID: { value: control.value } }; } + + return undefined; } validateMonAddr(control: AbstractControl) { if (!control.value.match(/^[,; ]*([\w.\-_\[\]]+(:[\d]+)?[,; ]*)*$/)) { return { invalidMonAddr: { value: control.value } }; } + + return undefined; } validateKey(control: AbstractControl) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts index 3b140e07b43..7c0830ce1cd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts @@ -164,6 +164,8 @@ export class PoolListComponent implements OnInit, OnDestroy { if (pool && pool['peer_uuids']) { return pool['peer_uuids'][0]; } + + return undefined; } updateSelection(selection: CdTableSelection) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-list/rbd-namespace-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-list/rbd-namespace-list.component.ts index ca6bb9d137b..36a241eb832 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-list/rbd-namespace-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-namespace-list/rbd-namespace-list.component.ts @@ -158,5 +158,7 @@ export class RbdNamespaceListComponent implements OnInit { return this.i18n('Namespace contains images'); } } + + return undefined; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts index bf3e89a6809..3086a1a5a2a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts @@ -96,5 +96,7 @@ export class RbdSnapshotActionsModel { if (!featuresName.includes('layering')) { return this.i18n('Parent image must support Layering'); } + + return undefined; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts index d17888d4ae2..d0652cb00be 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts @@ -81,6 +81,8 @@ export class ConfigurationFormComponent implements OnInit { return typeValidators.validators; } + + return undefined; } getStep(type: string, value: number): number | undefined { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts index f22f4c6b59d..40ccb8b8ddc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts @@ -158,5 +158,7 @@ export class HostsComponent implements OnInit { if (!this.orchestratorAvailable) { return this.i18n('Host operation is disabled because orchestrator is unavailable'); } + + return undefined; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.ts index 47635095d2c..755f3e73d5f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.ts @@ -139,6 +139,8 @@ export class MgrModuleListComponent { return this.i18n('This Manager module is always on.'); } } + + return undefined; } /** diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts index ce02f7c4b66..78784867983 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts @@ -369,7 +369,7 @@ export class PoolFormComponent implements OnInit { getMinSize(): number { if (!this.info || this.info.osd_count < 1) { - return; + return undefined; } const rule = this.form.getValue('crushRule'); if (rule) { @@ -380,7 +380,7 @@ export class PoolFormComponent implements OnInit { getMaxSize(): number { if (!this.info || this.info.osd_count < 1) { - return; + return undefined; } const osds: number = this.info.osd_count; if (this.form.getValue('crushRule')) { @@ -417,6 +417,8 @@ export class PoolFormComponent implements OnInit { if (sizeControl.valid && size > 0) { return pgs / size; } + + return undefined; } private erasurePgCalc(pgs): number { @@ -425,6 +427,8 @@ export class PoolFormComponent implements OnInit { if ((ecpControl.valid || ecpControl.disabled) && ecp) { return pgs / (ecp.k + ecp.m); } + + return undefined; } private alignPgs(pgs = this.form.getValue('pgNum')) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts index 72a330c1250..ee7cfe7a461 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts @@ -291,5 +291,7 @@ export class PoolListComponent implements OnInit { 'Pool deletion is disabled by the mon_allow_pool_delete configuration setting.' ); } + + return undefined; } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts index 2dfede6ca19..d13c4b1d3f6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts @@ -71,6 +71,8 @@ export class NavigationComponent implements OnInit { return { color: '#f0ad4e' }; } } + + return undefined; } toggleSubMenu(menu: string) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/pwd-expiration-notification/pwd-expiration-notification.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/pwd-expiration-notification/pwd-expiration-notification.component.ts index 94e64b5ecf6..676fe5148e8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/pwd-expiration-notification/pwd-expiration-notification.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/pwd-expiration-notification/pwd-expiration-notification.component.ts @@ -37,11 +37,9 @@ export class PwdExpirationNotificationComponent implements OnInit { } private getExpirationDays(pwdExpirationDate: number): number { - if (pwdExpirationDate) { - const current = new Date(); - const expiration = new Date(pwdExpirationDate * 1000); - return Math.floor((expiration.valueOf() - current.valueOf()) / (1000 * 3600 * 24)); - } + const current = new Date(); + const expiration = new Date(pwdExpirationDate * 1000); + return Math.floor((expiration.valueOf() - current.valueOf()) / (1000 * 3600 * 24)); } close() { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts index 824c9b74edd..57714dbae6b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts @@ -80,7 +80,7 @@ export class TableActionsComponent implements OnInit { */ getCurrentButton(): CdTableAction { if (this.dropDownOnly) { - return; + return undefined; } let buttonAction = this.dropDownActions.find((tableAction) => this.showableAction(tableAction)); if (!buttonAction && this.dropDownActions.length > 0) { @@ -104,7 +104,7 @@ export class TableActionsComponent implements OnInit { useRouterLink(action: CdTableAction): string { if (!action.routerLink || this.disableSelectionAction(action)) { - return; + return undefined; } return _.isString(action.routerLink) ? action.routerLink : action.routerLink(); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts index 8006bf72184..b3b4acd2cb3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.ts @@ -112,7 +112,7 @@ export class TableKeyValueComponent implements OnInit, OnChanges { private makePairs(data: any): KeyValueItem[] { let result: KeyValueItem[] = []; if (!data) { - return; // Wait for data + return undefined; // Wait for data } else if (_.isArray(data)) { result = this.makePairsFromArray(data); } else if (_.isObject(data)) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts index 7425183f4b1..f3dd70f3fb7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts @@ -8,9 +8,9 @@ export class FilterPipe implements PipeTransform { return value.filter((row) => { let result = true; - args.forEach((filter) => { + args.forEach((filter): boolean | void => { if (!filter.value) { - return; + return undefined; } result = result && filter.applyFilter(row, filter.value); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.ts index c9bb9729dd8..548dd00c565 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-silence-matcher.service.ts @@ -34,7 +34,7 @@ export class PrometheusSilenceMatcherService { rules: PrometheusRule[] ): AlertmanagerSilenceMatcherMatch { if (matchers.some((matcher) => matcher.isRegex)) { - return; + return undefined; } matchers.forEach((matcher) => { rules = this.getMatchedRules(matcher, rules); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts index af3e924a786..05cd7398f30 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-list.service.ts @@ -88,7 +88,7 @@ export class TaskListService implements OnDestroy { private getTaskAction(tasks: ExecutingTask[]): string { if (tasks.length === 0) { - return; + return undefined; } return tasks .map((task) => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts index 0f882bc8f4d..4081a81829b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/time-diff.service.ts @@ -37,7 +37,7 @@ export class TimeDiffService { calculateDate(date: Date, duration: string, reverse?: boolean): Date { const time = +date; if (_.isNaN(time)) { - return; + return undefined; } const diff = this.getDurationMs(duration) * (reverse ? -1 : 1); return new Date(time + diff); diff --git a/src/pybind/mgr/dashboard/frontend/tsconfig.json b/src/pybind/mgr/dashboard/frontend/tsconfig.json index 920370ad7ea..7c38858a5e0 100644 --- a/src/pybind/mgr/dashboard/frontend/tsconfig.json +++ b/src/pybind/mgr/dashboard/frontend/tsconfig.json @@ -14,6 +14,7 @@ "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, "noImplicitThis": true, + "noImplicitReturns": true, "target": "es2015", "typeRoots": [ "node_modules/@types"