Skip to content

Commit

Permalink
feat: mark findings as ignored in tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
acke committed Apr 2, 2024
1 parent ea1cfb8 commit 441e980
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/snyk/common/languageServer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Issue<T> = {
severity: IssueSeverity;
filePath: string;
additionalData: T;
isIgnored: boolean;
};

export enum IssueSeverity {
Expand Down
14 changes: 12 additions & 2 deletions src/snyk/snykCode/views/issueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@ export class IssueTreeProvider extends ProductIssueTreeProvider<CodeIssueData> {
getRunTestMessage = () => messages.runTest;

// The title in the tree is taken from the title for vulnerabilities and from the message for quality rules
getIssueTitle = (issue: Issue<CodeIssueData>) =>
issue.additionalData.isSecurityType ? issue.title.split(':')[0] : issue.additionalData.message.split('.')[0];
getIssueTitle(issue: Issue<CodeIssueData>): string {
let issueTitle = issue.additionalData.isSecurityType

Check warning on line 37 in src/snyk/snykCode/views/issueTreeProvider.ts

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-latest)

'issueTitle' is never reassigned. Use 'const' instead

Check warning on line 37 in src/snyk/snykCode/views/issueTreeProvider.ts

View workflow job for this annotation

GitHub Actions / Build and Test (macos-latest)

'issueTitle' is never reassigned. Use 'const' instead

Check warning on line 37 in src/snyk/snykCode/views/issueTreeProvider.ts

View workflow job for this annotation

GitHub Actions / Build and Test (windows-latest)

'issueTitle' is never reassigned. Use 'const' instead
? issue.title.split(':')[0]
: issue.additionalData.message.split('.')[0];

let prefixIgnored = '';
if (issue.isIgnored) {
prefixIgnored = '[ Ignored ] ';
}

return prefixIgnored + issueTitle;
}

getIssueRange(issue: Issue<CodeIssueData>): Range {
return IssueUtils.createVsCodeRange(issue.additionalData, this.languages);
Expand Down
1 change: 1 addition & 0 deletions src/test/unit/common/services/learnService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ suite('LearnService', () => {
title: 'not used',
severity: IssueSeverity.Critical,
filePath: 'not used',
isIgnored: false,
};

await learnService.getCodeLesson(issue);
Expand Down

0 comments on commit 441e980

Please sign in to comment.