Skip to content

Commit

Permalink
chore: trusted content support enhancements and fixes (#232)
Browse files Browse the repository at this point in the history
* chore: recommend Red Hat GA repository on recommendation and remediation

Signed-off-by: Ilona Shishov <[email protected]>

* fix: duplicate recommendations

Signed-off-by: Ilona Shishov <[email protected]>

---------

Signed-off-by: Ilona Shishov <[email protected]>
  • Loading branch information
IlonaShishov authored Dec 18, 2023
1 parent 0ef809e commit 70751c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/codeActionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function generateSwitchToRecommendedVersionAction(title: string, versionReplacem
newText: versionReplacementString
}];

if (diagnostic.severity !== 1 && path.basename(uri) === 'pom.xml') {
if (path.basename(uri) === 'pom.xml') {
codeAction.command = {
title: 'RedHat repository recommendation',
command: globalConfig.triggerRHRepositoryRecommendationNotification,
Expand Down
51 changes: 18 additions & 33 deletions src/diagnosticsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,42 +124,27 @@ class DiagnosticsPipeline implements IDiagnosticsPipeline {
* @returns A Promise that resolves when diagnostics are completed.
*/
async function performDiagnostics(diagnosticFilePath: string, contents: string, provider: IDependencyProvider) {

// collect dependencies from manifest file
let dependencies = null;
dependencies = await provider.collect(contents)
.catch(error => {
connection.console.warn(`Component Analysis Error: ${error}`);
connection.sendNotification('caError', {
errorMessage: error.message,
uri: diagnosticFilePath,
});
return;
});
const dependencyMap = new DependencyMap(dependencies);
try {
const dependencies = await provider.collect(contents);
const dependencyMap = new DependencyMap(dependencies);

const diagnosticsPipeline = new DiagnosticsPipeline(provider, dependencyMap, diagnosticFilePath);

clearCodeActionsMap();

diagnosticsPipeline.clearDiagnostics();

const analysis = executeComponentAnalysis(diagnosticFilePath, contents)
.then(response => {
diagnosticsPipeline.runDiagnostics(response.dependencies);
})
.catch(error => {
connection.console.warn(`Component Analysis Error: ${error}`);
connection.sendNotification('caError', {
errorMessage: error.message,
uri: diagnosticFilePath,
});
return;
});
const diagnosticsPipeline = new DiagnosticsPipeline(provider, dependencyMap, diagnosticFilePath);
diagnosticsPipeline.clearDiagnostics();

await analysis;
const response = await executeComponentAnalysis(diagnosticFilePath, contents);

diagnosticsPipeline.reportDiagnostics();
clearCodeActionsMap();

diagnosticsPipeline.runDiagnostics(response.dependencies);

diagnosticsPipeline.reportDiagnostics();
} catch (error) {
connection.console.warn(`Component Analysis Error: ${error}`);
connection.sendNotification('caError', {
errorMessage: error.message,
uri: diagnosticFilePath,
});
}
}

export { performDiagnostics };

0 comments on commit 70751c9

Please sign in to comment.