Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export async function execCLI<T extends CliArgs>(argv: T) {
const result = await customSpectral.run(apiSpecDocument);

const customDiagnostic = new RapLPDiagnostic(context);
customDiagnostic.processRuleExecutionInformation(result, enabledRulesAndCategorys.instanceCategoryMap);
customDiagnostic.processRuleExecutionInformation(result, enabledRulesAndCategorys.rules,enabledRulesAndCategorys.instanceCategoryMap);
const diagnosticReports: DiagnosticReport[] = customDiagnostic.processDiagnosticInformation();
if (argv.dex != null) {
const reportHandler = new ExcelReportProcessor({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const registerValidationRoutes = (app: Express) => {

const enabledRulesAndCategorys = await importAndCreateRuleInstances(ruleCategories);
const customDiagnostic = new RapLPDiagnostic(context);
customDiagnostic.processRuleExecutionInformation(data.result, enabledRulesAndCategorys.instanceCategoryMap);
customDiagnostic.processRuleExecutionInformation(data.result, enabledRulesAndCategorys.rules,enabledRulesAndCategorys.instanceCategoryMap);
const diagnosticReports: DiagnosticReport[] = customDiagnostic.processDiagnosticInformation();

try {
Expand Down
17 changes: 11 additions & 6 deletions src/util/RapLPDiagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,27 @@ class RapLPDiagnostic {
constructor(private context: RuleExecutionContext) {}
processRuleExecutionInformation(
raplpCustomResult: RapLPCustomSpectralDiagnostic[],
rules: Record<string, any>,
instanceCategoryMap: Map<string, any>,
): void {
this.processRuleExecutionLog(this.context.ruleExecutionLogDictionary, raplpCustomResult, instanceCategoryMap);
this.processRuleExecutionLog(this.context.ruleExecutionLogDictionary, raplpCustomResult, instanceCategoryMap,rules);
}
private processRuleExecutionLog(
log: RuleExecutionLog,
spectralResults: RapLPCustomSpectralDiagnostic[],
instanceCategoryMap: Map<string, any>,
rules: Record<string, any>,
) {
let executedRuleIds = new Set<string>(); // Set to track executed rule IDs
let executedRuleIdsWithError = new Set<string>(); // Set to track executed rule IDs with error
let ruleIdsNotApplicable = new Set<string>(); // Set to track rules that are not applicable, that is the (Δ) between the two above sets

const ruleIdToMessage = new Map<string, string>();

for (const key in log) {
const rules = log[key];
const { moduleName, className } = rules[0]; // Get module and class name from the first entry

//console.log(`Rule execution status for ${moduleName}:${className}:`);

rules.forEach((rule) => {
const { customProperties, severity, passed, targetVal } = rule;
const status = passed ? 'PASSED' : 'FAILED';
Expand All @@ -52,6 +54,7 @@ class RapLPDiagnostic {
this._ruleSets.executedUniqueRulesWithError.push({
id: customProperties.id, // Store some more diagnostic info (Duplicate NOT OK)
område: customProperties.område,
krav: rules[key]?.message ?? '',
});
}
}
Expand All @@ -64,6 +67,7 @@ class RapLPDiagnostic {
this._ruleSets.executedUniqueRules.push({
id: customProperties.id, // Store some more diagnostic info (Duplicate OK)
område: customProperties.område,
krav:rules[key]?.message ?? '',
});
}
executedRuleIds.add(customProperties.id); // Store current ID of rule with NO error
Expand All @@ -78,7 +82,7 @@ class RapLPDiagnostic {
});
if (!ruleIdsNotApplicable.has(customProperties.id) && !exists) {
// If not present, store the id and område in the not applicableRules
this._ruleSets.notApplicableRules.push({ id: customProperties.id, område: customProperties.område }); // Rules
this._ruleSets.notApplicableRules.push({ id: customProperties.id, område: customProperties.område, krav: rules[key]?.message ?? ''}); // Rules
}
}
}
Expand All @@ -94,7 +98,7 @@ class RapLPDiagnostic {
'N/A',
'Godkända regler - RAP-LP',
),
);
);
}
if (
this.diagnosticInformation.executedUniqueRulesWithError &&
Expand Down Expand Up @@ -156,6 +160,7 @@ interface DiagnosticRuleinfoSet {
interface DiagnosticRuleInfo {
id: string;
område: string;
krav: string;
}
interface PopulatedDiagnosticRuleInfo extends DiagnosticRuleInfo {
status: string;
Expand Down
2 changes: 1 addition & 1 deletion src/util/apiUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function processApiSpec(


const customDiagnostic = new RapLPDiagnostic(context);
customDiagnostic.processRuleExecutionInformation(result, enabledRulesAndCategorys.instanceCategoryMap);
customDiagnostic.processRuleExecutionInformation(result, enabledRulesAndCategorys.rules,enabledRulesAndCategorys.instanceCategoryMap);
const diagnosticReports: DiagnosticReport[] = customDiagnostic.processDiagnosticInformation();
return { result, report: diagnosticReports };
}
Expand Down