Skip to content

Commit

Permalink
[fix] Guideline stat API refactoring
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cservakt committed Jan 24, 2025
1 parent 7be4952 commit a78625f
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 13 deletions.
Binary file modified web/api/js/codechecker-api-node/dist/codechecker-api-6.60.0.tgz
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
6 changes: 1 addition & 5 deletions web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2790,11 +2790,7 @@ 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
checkers = [checker_name for checker_name in
self._context.checker_labels.checkers_by_labels(
[f"{guideline.guidelineName}:{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

0 comments on commit a78625f

Please sign in to comment.