Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong committed Oct 27, 2023
1 parent 1ceb67f commit 0849da4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/snyk/common/views/issueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid
abstract getIssueTitle(issue: Issue<T>): string;

abstract getIssueRange(issue?: Issue<T>): Range | undefined;
abstract getOpenIssueCommand(issue: Issue<T>, folderPath: string, filePath: string, filteredIssues?: Issue<T>[]): Command;
abstract getOpenIssueCommand(
issue: Issue<T>,
folderPath: string,
filePath: string,
filteredIssues?: Issue<T>[],
): Command;

getRootChildren(): TreeNode[] {
const nodes: TreeNode[] = [];
Expand Down
32 changes: 22 additions & 10 deletions src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import marked from 'marked';
import * as marked from 'marked';
import { Command, Uri } from 'vscode';
import { OpenCommandIssueType, OpenIssueCommandArg } from '../../common/commands/types';
import { IConfiguration } from '../../common/configuration/configuration';
Expand Down Expand Up @@ -71,7 +71,9 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs

const fileSeverityCounts = this.initSeverityCounts();

const uniqueIssues = fileIssues.filter((issue, index, self) => index === self.findIndex(t => t.id === issue.id));
const uniqueIssues = fileIssues.filter(
(issue, index, self) => index === self.findIndex(t => t.id === issue.id),
);

const filteredIssues = this.filterIssues(uniqueIssues);

Expand Down Expand Up @@ -153,7 +155,9 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs
}

getIssueFoundText(nIssues: number): string {
return `Snyk found ${!nIssues ? 'no vulnerabilities! ✅' : `${nIssues} ${nIssues === 1 ? 'vulnerability' : 'vulnerabilities'}`}`;
return `Snyk found ${
!nIssues ? 'no vulnerabilities! ✅' : `${nIssues} ${nIssues === 1 ? 'vulnerability' : 'vulnerabilities'}`
}`;
}

filterIssues(issues: Issue<OssIssueData>[]): Issue<OssIssueData>[] {
Expand All @@ -179,7 +183,12 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs

getIssueRange = () => undefined;

getOpenIssueCommand(issue: Issue<OssIssueData>, _folderPath: string, _filePath: string, filteredIssues: Issue<OssIssueData>[]): Command {
getOpenIssueCommand(
issue: Issue<OssIssueData>,
_folderPath: string,
_filePath: string,
filteredIssues: Issue<OssIssueData>[],
): Command {
return {
command: SNYK_OPEN_ISSUE_COMMAND,
title: '',
Expand All @@ -192,21 +201,24 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs
};
}

getOssIssueCommandArg(vuln: Issue<OssIssueData>, filteredVulns: Issue<OssIssueData>[]): OssIssueCommandArgLanguageServer {
getOssIssueCommandArg(
vuln: Issue<OssIssueData>,
filteredVulns: Issue<OssIssueData>[],
): OssIssueCommandArgLanguageServer {
const matchingIdVulnerabilities = filteredVulns.filter(v => v.id === vuln.id);
let overviewHtml: string;
let overviewHtml = '';

try {
// TODO: marked.parse does not sanitize the HTML. See: https://marked.js.org/#usage
overviewHtml = marked.parse(vuln.additionalData.description);
console.log('****', 'overviewHtml ****\n', overviewHtml, '\n');
} catch (error) {
console.log('****', 'overviewHtml error ****\n', error, '\n');
overviewHtml = '<p>There was a problem rendering the vulnerability overview</p>';
}

return {
...vuln,
matchingIdVulnerabilities,
overviewHtml: vuln.additionalData.description,
overviewHtml,
};
};
}
}

0 comments on commit 0849da4

Please sign in to comment.