From ba5e1e059395b93209e9ba1e8787cdcf714f0225 Mon Sep 17 00:00:00 2001 From: Teodora Sandu Date: Mon, 29 Apr 2024 14:25:03 +0100 Subject: [PATCH] refactor: remove unused code --- .../common/configuration/configuration.ts | 16 -------- src/test/unit/common/configuration.test.ts | 41 ------------------- 2 files changed, 57 deletions(-) diff --git a/src/snyk/common/configuration/configuration.ts b/src/snyk/common/configuration/configuration.ts index fec4f0e08..d47cfcea0 100644 --- a/src/snyk/common/configuration/configuration.ts +++ b/src/snyk/common/configuration/configuration.ts @@ -53,7 +53,6 @@ export interface IConfiguration { source: string; authHost: string; - baseApiUrl: string; getToken(): Promise; @@ -97,8 +96,6 @@ export interface IConfiguration { isFedramp: boolean; - analyticsPermitted: boolean; - severityFilter: SeverityFilter; scanningMode: string | undefined; @@ -117,8 +114,6 @@ export class Configuration implements IConfiguration { private readonly defaultSnykCodeBaseURL = 'https://deeproxy.snyk.io'; private readonly defaultAuthHost = 'https://snyk.io'; private readonly defaultOssApiEndpoint = `${this.defaultAuthHost}/api/v1`; - private readonly defaultBaseApiHost = 'https://api.snyk.io'; - private readonly analyticsPermittedEnvironments = { 'app.snyk.io': true, 'app.us.snyk.io': true }; constructor(private processEnv: NodeJS.ProcessEnv = process.env, private workspace: IVSCodeWorkspace) {} @@ -204,13 +199,6 @@ export class Configuration implements IConfiguration { return `${hostnameParts[2]}.${hostnameParts[3]}`.includes('snykgov.io'); } - get analyticsPermitted(): boolean { - if (!this.customEndpoint) return true; - - const hostname = new URL(this.customEndpoint).hostname; - return hostname in this.analyticsPermittedEnvironments; - } - get snykOssApiEndpoint(): string { if (this.customEndpoint) { return this.customEndpoint; // E.g. https://app.eu.snyk.io/api @@ -292,10 +280,6 @@ export class Configuration implements IConfiguration { return Configuration.source; } - get baseApiUrl(): string { - return this.defaultBaseApiHost; - } - getFeaturesConfiguration(): FeaturesConfiguration { const ossEnabled = this.workspace.getConfiguration( CONFIGURATION_IDENTIFIER, diff --git a/src/test/unit/common/configuration.test.ts b/src/test/unit/common/configuration.test.ts index 797956f7b..3f95c8ddc 100644 --- a/src/test/unit/common/configuration.test.ts +++ b/src/test/unit/common/configuration.test.ts @@ -229,45 +229,4 @@ suite('Configuration', () => { strictEqual(configuration.isFedramp, false); }); }); - - suite('.analyticsPermitted()', () => { - test('returns true when no custom endpoint configured', () => { - const workspace = stubWorkspaceConfiguration(ADVANCED_CUSTOM_ENDPOINT, undefined); - - const configuration = new Configuration({}, workspace); - strictEqual(configuration.analyticsPermitted, true); - }); - - test('returns true for app.snyk.io', () => { - const customEndpoint = 'https://app.snyk.io'; - const workspace = stubWorkspaceConfiguration(ADVANCED_CUSTOM_ENDPOINT, customEndpoint); - - const configuration = new Configuration({}, workspace); - strictEqual(configuration.analyticsPermitted, true); - }); - - test('returns true for app.us.snyk.io', () => { - const customEndpoint = 'https://app.us.snyk.io'; - const workspace = stubWorkspaceConfiguration(ADVANCED_CUSTOM_ENDPOINT, customEndpoint); - - const configuration = new Configuration({}, workspace); - strictEqual(configuration.analyticsPermitted, true); - }); - - test('returns false for app.snykgov.io', () => { - const customEndpoint = 'https://app.snykgov.io'; - const workspace = stubWorkspaceConfiguration(ADVANCED_CUSTOM_ENDPOINT, customEndpoint); - - const configuration = new Configuration({}, workspace); - strictEqual(configuration.analyticsPermitted, false); - }); - - test('returns false for app.eu.snyk.io', () => { - const customEndpoint = 'https://app.eu.snyk.io'; - const workspace = stubWorkspaceConfiguration(ADVANCED_CUSTOM_ENDPOINT, customEndpoint); - - const configuration = new Configuration({}, workspace); - strictEqual(configuration.analyticsPermitted, false); - }); - }); });