Skip to content

Commit

Permalink
Merge pull request Ericsson#4247 from cservakt/add-guideline-to-check…
Browse files Browse the repository at this point in the history
…ercoverage

[feature] Adding guideline label to Checker Coverage tab
  • Loading branch information
dkrupp authored Jun 3, 2024
2 parents e2037fa + 62023c3 commit 0610134
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,26 @@
</span>
</template>

<template #item.guidelineRules="{ item }">
<div v-if="item.guidelineRules.length">
<div
v-for="guidelineRule in item.guidelineRules"
:key="guidelineRule.type"
>
<span class="type">
{{ guidelineRule.type }}:
</span>
<span
v-for="rule in guidelineRule.rules"
:key="rule"
:style="getRuleStyle(guidelineRule)"
>
{{ rule }}
</span>
</div>
</div>
</template>

<template v-if="necessaryTotal" slot="body.append">
<tr>
<td class="text-center" :colspan="colspan">
Expand Down Expand Up @@ -445,6 +465,13 @@ export default {
query["severity"] = this.severityFromCodeToString(severity);
return query;
},
getRuleStyle(guidelineRule) {
return {
display: guidelineRule.rules.length > 1 ? "block" : "inline-block",
"margin-left": guidelineRule.rules.length > 1 ? "1em" : "0"
};
}
}
};
Expand All @@ -462,4 +489,8 @@ export default {
text-decoration: underline;
}
}
.type {
font-weight: bold;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import { BaseStatistics } from "@/components/Statistics";
import CheckerCoverageStatisticsTable from "./CheckerCoverageStatisticsTable";
import CheckerCoverageStatisticsDialog from "./CheckerCoverageStatisticsDialog";
import {
Checker,
MAX_QUERY_SIZE,
ReportFilter,
RunFilter
Expand Down Expand Up @@ -175,6 +176,7 @@ export default {
return {
checker: stat[checker_id].checkerName,
severity: stat[checker_id].severity,
guidelineRules: stat[checker_id].guidelineRules,
enabledInAllRuns: stat[checker_id].disabled.length === 0
? 1
: 0,
Expand All @@ -201,12 +203,13 @@ export default {
downloadCSV() {
const data = [
[
"Checker Name", "Severity", "Status",
"Checker Name", "guideline", "Severity", "Status",
"Closed Reports", "Outstanding Reports",
],
...this.statistics.map(stat => {
return [
stat.checker,
this.formattedGuidelines(stat.guidelineRules),
this.severityFromCodeToString(stat.severity),
stat.enabledInAllRuns
? "Enabled in all selected runs"
Expand Down Expand Up @@ -261,7 +264,7 @@ export default {
const filter = new ReportFilter(this.reportFilter);
this.checker_stat = await new Promise(resolve => {
const checker_stat = await new Promise(resolve => {
ccService.getClient().getCheckerStatusVerificationDetails(
this.runIds,
filter,
Expand All @@ -270,6 +273,49 @@ export default {
}));
});
if ( checker_stat !== undefined ) {
const checkers = Object.values(checker_stat).map(stat => {
return new Checker({
analyzerName: stat.analyzerName,
checkerId: stat.checkerName
});
});
const guidelineRules = await new Promise(resolve => {
ccService.getClient().getCheckerLabels(
checkers,
handleThriftError(labels => {
resolve(labels.map(label => {
const guidelines = label.filter(
param => param.startsWith("guideline")
);
return guidelines.map(g => {
const guideline = g.split("guideline:")[1];
const guidelineLabels = label.filter(
param => param.startsWith(guideline)
);
return {
type: guideline,
rules: guidelineLabels.map(gl => {
return gl.split(`${guideline}:`)[1];
})
};
});
}));
})
);
});
Object.keys(checker_stat).forEach(
(key, index) => {
checker_stat[key]["guidelineRules"] = guidelineRules[index]
!== undefined
? guidelineRules[index]
: null;
});
}
this.checker_stat = checker_stat;
this.loading = false;
},
Expand Down Expand Up @@ -330,6 +376,13 @@ export default {
else {
this.noProperRun = true;
}
},
formattedGuidelines(guidelineRules) {
return guidelineRules.map(guidelineRule => {
const rules = guidelineRule.rules.join("; ");
return `${guidelineRule.type}: ${rules}`;
}).join(" ");
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default {
text: "Checker Name",
value: "checker"
},
{
text: "Guideline",
value: "guidelineRules"
},
{
text: "Severity",
value: "severity",
Expand Down

0 comments on commit 0610134

Please sign in to comment.