Skip to content

Commit 1a447f7

Browse files
fix: add message to report (#517)
Signed-off-by: Fredrik Nordlander <fredrik.nordlander@digg.se>
1 parent 70ddb7d commit 1a447f7

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/util/RapLPDiagnostic.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ class RapLPDiagnostic {
2222
rules: Record<string, any>,
2323
instanceCategoryMap: Map<string, any>,
2424
): void {
25-
this.processRuleExecutionLog(this.context.ruleExecutionLogDictionary, raplpCustomResult, instanceCategoryMap,rules);
25+
this.processRuleExecutionLog(
26+
this.context.ruleExecutionLogDictionary,
27+
raplpCustomResult,
28+
instanceCategoryMap,
29+
rules,
30+
);
2631
}
2732
private processRuleExecutionLog(
2833
log: RuleExecutionLog,
@@ -33,17 +38,17 @@ class RapLPDiagnostic {
3338
let executedRuleIds = new Set<string>(); // Set to track executed rule IDs
3439
let executedRuleIdsWithError = new Set<string>(); // Set to track executed rule IDs with error
3540
let ruleIdsNotApplicable = new Set<string>(); // Set to track rules that are not applicable, that is the (Δ) between the two above sets
36-
const ruleIdToMessage = new Map<string, string>();
37-
41+
3842
for (const key in log) {
39-
const rules = log[key];
40-
const { moduleName, className } = rules[0]; // Get module and class name from the first entry
43+
const execRules = log[key];
44+
const { className } = execRules[0]; // Get module and class name from the first entry
4145
//console.log(`Rule execution status for ${moduleName}:${className}:`);
42-
43-
rules.forEach((rule) => {
46+
47+
execRules.forEach((rule) => {
4448
const { customProperties, severity, passed, targetVal } = rule;
4549
const status = passed ? 'PASSED' : 'FAILED';
4650
const severityText = severity.toUpperCase();
51+
const message = rules[className]?.message ?? ''; // Lookup instance message
4752
// Check if rule is found in Spectral results
4853
const spectralResult = spectralResults.find((result) => {
4954
return result.område === customProperties.område && result.id === customProperties.id;
@@ -55,8 +60,8 @@ class RapLPDiagnostic {
5560
this._ruleSets.executedUniqueRulesWithError.push({
5661
id: customProperties.id, // Store some more diagnostic info (Duplicate NOT OK)
5762
område: customProperties.område,
58-
krav: rules[key]?.message ?? '',
5963
helpUrl: customProperties.id ? buildRuleHelpUrl(customProperties.id) : undefined,
64+
krav: message,
6065
});
6166
}
6267
}
@@ -69,8 +74,8 @@ class RapLPDiagnostic {
6974
this._ruleSets.executedUniqueRules.push({
7075
id: customProperties.id, // Store some more diagnostic info (Duplicate OK)
7176
område: customProperties.område,
72-
krav:rules[key]?.message ?? '',
7377
helpUrl: customProperties.id ? buildRuleHelpUrl(customProperties.id) : undefined,
78+
krav: message,
7479
});
7580
}
7681
executedRuleIds.add(customProperties.id); // Store current ID of rule with NO error
@@ -85,9 +90,9 @@ class RapLPDiagnostic {
8590
});
8691
if (!ruleIdsNotApplicable.has(customProperties.id) && !exists) {
8792
// If not present, store the id and område in the not applicableRules
88-
this._ruleSets.notApplicableRules.push({
89-
id: customProperties.id,
90-
område: customProperties.område,
93+
this._ruleSets.notApplicableRules.push({
94+
id: customProperties.id,
95+
område: customProperties.område,
9196
krav: rules[key]?.message ?? '',
9297
helpUrl: customProperties.id ? buildRuleHelpUrl(customProperties.id) : undefined,
9398
}); // Rules
@@ -106,7 +111,7 @@ class RapLPDiagnostic {
106111
'N/A',
107112
'Godkända regler - RAP-LP',
108113
),
109-
);
114+
);
110115
}
111116
if (
112117
this.diagnosticInformation.executedUniqueRulesWithError &&
@@ -171,7 +176,6 @@ interface DiagnosticRuleInfo {
171176
krav: string;
172177
/**Helper Url for guidelines */
173178
helpUrl?: string;
174-
175179
}
176180
interface PopulatedDiagnosticRuleInfo extends DiagnosticRuleInfo {
177181
status: string;

0 commit comments

Comments
 (0)