Skip to content

Commit 748366f

Browse files
committed
[fix] Guideline stat API refactoring
It is a wanted fix. The purpose of this PR to get rid of the severity of Rule struct to get a better form. I think it needs more API endpoint calls and it gets slower but the Guideline stat endpoint is pretty at least.
1 parent 7be4952 commit 748366f

File tree

8 files changed

+56
-20
lines changed

8 files changed

+56
-20
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

web/api/report_server.thrift

+4-4
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,10 @@ struct Guideline {
553553
}
554554

555555
struct Rule {
556-
1: string ruleId, // The identifier of the rule.
557-
2: string title, // The rule summary.
558-
3: string url, // The link of the rule page.
559-
4: list<map<string, string>> checkers // List of checker names
556+
1: string ruleId, // The identifier of the rule.
557+
2: string title, // The rule summary.
558+
3: string url, // The link of the rule page.
559+
4: list<string> checkers // List of checker names
560560
}
561561
typedef map<string, list<Rule>> GuidelineRules
562562

web/server/codechecker_server/api/report_server.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -2790,13 +2790,8 @@ def getGuidelineRules(
27902790
guideline_rules[guideline.guidelineName] = []
27912791
continue
27922792
for rule in rules:
2793-
checkers = [{
2794-
"checkerName": checker_name,
2795-
"severity": self._context.checker_labels.severity(
2796-
checker_name).lower()
2797-
} for checker_name in
2798-
self._context.checker_labels.checkers_by_labels(
2799-
[f"{guideline.guidelineName}:{rule}"])]
2793+
checkers = self._context.checker_labels.checkers_by_labels(
2794+
[f"{guideline.guidelineName}:{rule}"])
28002795

28012796
guideline_rules[guideline.guidelineName].append(
28022797
Rule(

web/server/vue-cli/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/server/vue-cli/src/components/Statistics/Guideline/GuidelineStatistics.vue

+46-2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ import { BaseStatistics } from "@/components/Statistics";
131131
import GuidelineStatisticsTable from "./GuidelineStatisticsTable";
132132
import StatisticsDialog from "../StatisticsDialog";
133133
import {
134+
Checker,
134135
Guideline,
135136
MAX_QUERY_SIZE,
136137
ReportFilter,
@@ -304,9 +305,52 @@ export default {
304305
this.all_guideline_rules = await new Promise(resolve => {
305306
ccService.getClient().getGuidelineRules(
306307
this.selectedGuidelines,
307-
handleThriftError(guidelines => {
308+
handleThriftError(async guidelines => {
309+
for (const [ guideline, rules ] of Object.entries(guidelines)) {
310+
guidelines[guideline] = await Promise.all(
311+
rules.map(async rule => {
312+
const checkers = await Promise.all(
313+
rule.checkers.map(async checker => {
314+
const severity = await new Promise(resolve => {
315+
ccService.getClient().getCheckerLabels(
316+
[
317+
new Checker({
318+
analyzerName: null,
319+
checkerId: checker
320+
})
321+
],
322+
handleThriftError(labels => {
323+
const severityLabels = labels[0].filter(param =>
324+
param.startsWith("severity")
325+
);
326+
const severity = severityLabels.length
327+
? severityLabels[0].split("severity:")[1]
328+
: null;
329+
resolve(severity);
330+
})
331+
);
332+
});
333+
334+
return {
335+
checkerName: checker,
336+
severity: severity
337+
};
338+
})
339+
);
340+
341+
return {
342+
ruleId: rule.ruleId,
343+
title: rule.title,
344+
url: rule.url,
345+
checkers: checkers
346+
};
347+
})
348+
);
349+
}
350+
308351
resolve(guidelines);
309-
}));
352+
})
353+
);
310354
});
311355
},
312356

web/tests/functional/report_viewer_api/test_get_run_results.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,5 @@ def test_get_guideline_rules(self):
470470
sei_cert_rules))[0]
471471
self.assertEqual(len(con_54_cpp_rule.checkers), 1)
472472

473-
releated_checker = {
474-
"checkerName": "bugprone-spuriously-wake-up-functions",
475-
"severity": "medium"
476-
}
477-
self.assertEqual(con_54_cpp_rule.checkers, [releated_checker])
473+
self.assertEqual(con_54_cpp_rule.checkers,
474+
["bugprone-spuriously-wake-up-functions"])

0 commit comments

Comments
 (0)