Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Guideline stat API refactoring #4433

Merged
merged 1 commit into from
Jan 28, 2025
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
Binary file not shown.
Binary file modified web/api/py/codechecker_api/dist/codechecker_api.tar.gz
Binary file not shown.
Binary file not shown.
8 changes: 4 additions & 4 deletions web/api/report_server.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,10 @@ struct Guideline {
}

struct Rule {
1: string ruleId, // The identifier of the rule.
2: string title, // The rule summary.
3: string url, // The link of the rule page.
4: list<map<string, string>> checkers // List of checker names
1: string ruleId, // The identifier of the rule.
2: string title, // The rule summary.
3: string url, // The link of the rule page.
4: list<string> checkers // List of checker names
}
typedef map<string, list<Rule>> GuidelineRules

Expand Down
9 changes: 2 additions & 7 deletions web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2790,13 +2790,8 @@ def getGuidelineRules(
guideline_rules[guideline.guidelineName] = []
continue
for rule in rules:
checkers = [{
"checkerName": checker_name,
"severity": self._context.checker_labels.severity(
checker_name).lower()
} for checker_name in
self._context.checker_labels.checkers_by_labels(
[f"{guideline.guidelineName}:{rule}"])]
checkers = self._context.checker_labels.checkers_by_labels(
[f"{guideline.guidelineName}:{rule}"])

guideline_rules[guideline.guidelineName].append(
Rule(
Expand Down
4 changes: 2 additions & 2 deletions web/server/vue-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ import { BaseStatistics } from "@/components/Statistics";
import GuidelineStatisticsTable from "./GuidelineStatisticsTable";
import StatisticsDialog from "../StatisticsDialog";
import {
Checker,
Guideline,
MAX_QUERY_SIZE,
ReportFilter,
Expand Down Expand Up @@ -304,9 +305,52 @@ export default {
this.all_guideline_rules = await new Promise(resolve => {
ccService.getClient().getGuidelineRules(
this.selectedGuidelines,
handleThriftError(guidelines => {
handleThriftError(async guidelines => {
for (const [ guideline, rules ] of Object.entries(guidelines)) {
guidelines[guideline] = await Promise.all(
rules.map(async rule => {
const checkers = await Promise.all(
rule.checkers.map(async checker => {
const severity = await new Promise(resolve => {
ccService.getClient().getCheckerLabels(
[
new Checker({
analyzerName: null,
checkerId: checker
})
],
handleThriftError(labels => {
const severityLabels = labels[0].filter(param =>
param.startsWith("severity")
);
const severity = severityLabels.length
? severityLabels[0].split("severity:")[1]
: null;
resolve(severity);
})
);
});

return {
checkerName: checker,
severity: severity
};
})
);

return {
ruleId: rule.ruleId,
title: rule.title,
url: rule.url,
checkers: checkers
};
})
);
}

resolve(guidelines);
}));
})
);
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,5 @@ def test_get_guideline_rules(self):
sei_cert_rules))[0]
self.assertEqual(len(con_54_cpp_rule.checkers), 1)

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