Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move delta preview setting to settings [IDE-482] #497

Merged
merged 7 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@
"description": "Preview features that are currently in development. Setting keys will be removed when features become stable.",
"propertyNames": true,
"properties": {}
},
"snyk.netNewVsKnownIssues": {
"type": "string",
"default": "KnownIssues",
"description": "Specifies whether to see only net new issues or known issues. Only applies to Code Security and Code Quality.",
"enum": [
"KnownIssues",
"NetNewIssues"
],
"enumDescriptions": [
"Shows all issues that have been identified, including both new and existing issues.",
"Shows only new issues that have been introduced in the latest scan, filtering out previously known issues."
],
"markdownDescription": "Specifies whether to see only net new issues or known issues. Only applies to Code Security and Code Quality.\n\nNote: this is an experimental feature. Please reach out to [support.snyk.io](https://support.snyk.io) for more details."
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/snyk/common/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
import SecretStorageAdapter from '../vscode/secretStorage';
import { IVSCodeWorkspace } from '../vscode/workspace';

const NEWISSUES = 'NetNewIssues';

export type FeaturesConfiguration = {
ossEnabled: boolean | undefined;
codeSecurityEnabled: boolean | undefined;
Expand Down Expand Up @@ -61,7 +63,6 @@ export interface SeverityFilter {

export type PreviewFeatures = {
advisor: boolean | undefined;
deltaFindings: boolean | undefined;
};

export interface IConfiguration {
Expand Down Expand Up @@ -238,9 +239,11 @@ export class Configuration implements IConfiguration {
}

getDeltaFindingsEnabled(): boolean {
return (
this.workspace.getConfiguration<boolean>(CONFIGURATION_IDENTIFIER, this.getConfigName(DELTA_FINDINGS)) ?? false
const selectionValue = this.workspace.getConfiguration<string>(
CONFIGURATION_IDENTIFIER,
this.getConfigName(DELTA_FINDINGS),
);
return selectionValue === NEWISSUES;
}

async getToken(): Promise<string | undefined> {
Expand Down Expand Up @@ -435,7 +438,6 @@ export class Configuration implements IConfiguration {
getPreviewFeatures(): PreviewFeatures {
const defaultSetting: PreviewFeatures = {
advisor: false,
deltaFindings: false,
};

const userSetting =
Expand Down
2 changes: 1 addition & 1 deletion src/snyk/common/constants/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export const TRUSTED_FOLDERS = `${CONFIGURATION_IDENTIFIER}.trustedFolders`;
export const FOLDER_CONFIGS = `${CONFIGURATION_IDENTIFIER}.folderConfigs`;
export const SCANNING_MODE = `${CONFIGURATION_IDENTIFIER}.scanningMode`;

export const DELTA_FINDINGS = `${FEATURES_PREVIEW_SETTING}.deltaFindings`;
export const DELTA_FINDINGS = `${CONFIGURATION_IDENTIFIER}.netNewVsKnownIssues`;
7 changes: 4 additions & 3 deletions src/snyk/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class SnykExtension extends SnykLib implements IExtension {

this.statusBarItem.show();

const previewFeatures = configuration.getPreviewFeatures();
if (previewFeatures.deltaFindings) {
const isDeltaEnabled = configuration.getDeltaFindingsEnabled();
if (isDeltaEnabled) {
await this.contextService.setContext(SNYK_CONTEXT.DELTA_FINDINGS_ENABLED, true);
}

Expand Down Expand Up @@ -274,7 +274,8 @@ class SnykExtension extends SnykLib implements IExtension {

let securityCodeView = SNYK_VIEW_ANALYSIS_CODE_SECURITY;
let codeQualityView = SNYK_VIEW_ANALYSIS_CODE_QUALITY;
if (previewFeatures.deltaFindings) {

if (isDeltaEnabled) {
securityCodeView = SNYK_VIEW_ANALYSIS_CODE_SECURITY_WITH_DELTA;
codeQualityView = SNYK_VIEW_ANALYSIS_CODE_QUALITY_WITH_DELTA;
}
Expand Down
15 changes: 0 additions & 15 deletions src/test/unit/common/commands/commandController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,4 @@ suite('CommandController', () => {
// Assert
sinon.assert.calledOnceWithExactly(fakeFunc, args);
});

test("Doesn't execute debounced command within the debounce interval", async () => {
ShawkyZ marked this conversation as resolved.
Show resolved Hide resolved
// Arrange
const fakeFunc = sinon.fake();
const args = ['test', 0, true];

// Act
await controller.executeCommand('snyk.test', fakeFunc, args);
await sleep(COMMAND_DEBOUNCE_INTERVAL + 1);
await controller.executeCommand('snyk.test', fakeFunc, args);

// Assert
sinon.assert.calledTwice(fakeFunc);
sinon.assert.calledWith(fakeFunc, args);
});
});
2 changes: 0 additions & 2 deletions src/test/unit/common/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,12 @@ suite('Configuration', () => {

deepStrictEqual(configuration.getPreviewFeatures(), {
advisor: false,
deltaFindings: false,
} as PreviewFeatures);
});

test('Preview features: some features enabled', () => {
const previewFeatures = {
advisor: false,
deltaFindings: false,
} as PreviewFeatures;
const workspace = stubWorkspaceConfiguration(FEATURES_PREVIEW_SETTING, previewFeatures);

Expand Down
Loading