Skip to content

Commit

Permalink
fix: add cache properties to ca notification payload (#192)
Browse files Browse the repository at this point in the history
Signed-off-by: Arunprasad Rajkumar <[email protected]>
  • Loading branch information
arajkumar authored Apr 27, 2021
1 parent 8d2afe9 commit 953dc3c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ const regexVersion = new RegExp(/^([a-zA-Z0-9]+\.)?([a-zA-Z0-9]+\.)?([a-zA-Z0-9
const sendDiagnostics = async (ecosystem: string, diagnosticFilePath: string, contents: string, collector: IDependencyCollector) => {
// clear all diagnostics
connection.sendDiagnostics({ uri: diagnosticFilePath, diagnostics: [] });
connection.sendNotification('caNotification', {data: caDefaultMsg, done: false, uri: diagnosticFilePath});
connection.sendNotification('caNotification', {
data: caDefaultMsg,
done: false,
uri: diagnosticFilePath,
});

let deps = null;
try {
const start = new Date().getTime();
Expand All @@ -270,7 +275,10 @@ const sendDiagnostics = async (ecosystem: string, diagnosticFilePath: string, co
connection.console.log(`manifest parse took ${end - start} ms, found ${deps.length} deps`);
} catch (error) {
connection.console.warn(`Error: ${error}`);
connection.sendNotification('caError', {data: error, uri: diagnosticFilePath});
connection.sendNotification('caError', {
data: error,
uri: diagnosticFilePath,
});
return;
}

Expand Down Expand Up @@ -313,7 +321,16 @@ const sendDiagnostics = async (ecosystem: string, diagnosticFilePath: string, co
const end = new Date().getTime();

connection.console.log(`fetch vulns took ${end - start} ms`);
connection.sendNotification('caNotification', {data: getCAmsg(deps, diagnostics, totalCount), diagCount : diagnostics.length || 0, vulnCount: totalCount, depCount: deps.length || 0, done: true, uri: diagnosticFilePath});
connection.sendNotification('caNotification', {
data: getCAmsg(deps, diagnostics, totalCount),
diagCount : diagnostics.length || 0,
vulnCount: totalCount,
depCount: deps.length || 0,
done: true,
uri: diagnosticFilePath,
cacheHitCount: cachedValues.length,
cacheMissCount: missedItems.length,
});
};

files.on(EventStream.Diagnostics, "^package\\.json$", (uri, name, contents) => {
Expand Down

0 comments on commit 953dc3c

Please sign in to comment.