Skip to content

Commit

Permalink
refactor: consistent message across products when no issues are found
Browse files Browse the repository at this point in the history
  • Loading branch information
Catalina Oyaneder committed Jul 16, 2024
1 parent bfaecb0 commit e82fd27
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/snyk/common/views/issueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid
}

protected getIssueFoundText(nIssues: number, _: number): string {
return `Snyk found ${!nIssues ? 'no issues! ✅' : `${nIssues} issue${nIssues === 1 ? '' : 's'}`}`;
if (!nIssues) {
return '✅ Congrats! No issues found!';
}
return `Snyk found ${nIssues} issue${nIssues === 1 ? '' : 's'}`;
}

protected getIssueDescriptionText(dir: string | undefined, issueCount: number): string | undefined {
Expand Down
2 changes: 1 addition & 1 deletion src/snyk/snykCode/views/securityIssueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class CodeSecurityIssueTreeProvider extends IssueTreeProvider {
}
return text;
} else {
return '✅ Congrats! No vulnerabilities found!';
return '✅ Congrats! No issues found!';
}
}
}
5 changes: 4 additions & 1 deletion src/snyk/snykIac/views/iacIssueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export default class IacIssueTreeProvider extends ProductIssueTreeProvider<IacIs
}

getIssueFoundText(nIssues: number, _: number): string {
return `Snyk found ${!nIssues ? 'no issues! ✅' : `${nIssues} ${nIssues === 1 ? 'issue' : 'issues'}`}`;
if (!nIssues) {
return '✅ Congrats! No issues found!';
}
return `Snyk found ${nIssues} issue${nIssues === 1 ? '' : 's'}`;
}

filterIssues(issues: Issue<IacIssueData>[]): Issue<IacIssueData>[] {
Expand Down
2 changes: 1 addition & 1 deletion src/snyk/snykOss/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const messages = {
treeView: {
cookingDependencies: 'Scanning...',
runTest: 'Run scan for Open Source security vulnerabilities.',
noVulnerabilitiesFound: ' ✅ Congrats! Snyk found no vulnerabilities.',
noVulnerabilitiesFound: ' ✅ Congrats! No issues found!',
singleVulnerabilityFound: 'Snyk found 1 vulnerability',
vulnerability: 'vulnerability',
vulnerabilities: 'vulnerabilities',
Expand Down
7 changes: 4 additions & 3 deletions src/snyk/snykOss/providers/ossVulnerabilityTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ export default class OssIssueTreeProvider extends ProductIssueTreeProvider<OssIs
}

getIssueFoundText(nIssues: number, _: number): string {
return `Snyk found ${
!nIssues ? 'no vulnerabilities! ✅' : `${nIssues} ${nIssues === 1 ? 'vulnerability' : 'vulnerabilities'}`
}`;
if (!nIssues) {
return '✅ Congrats! No issues found!';
}
return `Snyk found ${nIssues} issue${nIssues === 1 ? '' : 's'}`;
}

filterIssues(issues: Issue<OssIssueData>[]): Issue<OssIssueData>[] {
Expand Down
2 changes: 1 addition & 1 deletion src/test/integration/issueTreeProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ suite('Code Issue Tree Provider', () => {
sinon.stub(issueTreeProvider, 'getResultNodes').returns([]);
const rootChildren = issueTreeProvider.getRootChildren();
strictEqual(rootChildren.length, 2);
strictEqual(rootChildren[0].label, 'Snyk found no issues! ✅');
strictEqual(rootChildren[0].label, '✅ Congrats! No issues found!');
strictEqual(rootChildren[1].label, 'There are no vulnerabilities fixable by Snyk DeepCode AI');
});

Expand Down

0 comments on commit e82fd27

Please sign in to comment.