forked from Ericsson/codechecker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new `Guideline statistics` tab on the Statistics page can list all rules for the selected guidelines. The user can select multiple guidelines (but currently the only one is `sei-cert` and it is the default). The table can show the checker statistics that are related to the specified guideline rule. Rules may connect to more than one checker or may not have any checker. The checker statistics are calculated for runs that are selected (or for all runs if no run selected) in the report filter. It can show guideline name, guideline rule, checker name, checker severity, checker status, number of closed and outstanding reports. The status informs the user about how many runs the given checker was enabled or disabled. Closed and outstanding report counts depend on review and detection status. New config dir was created to store guideline files. Each yaml file represents a guideline an contains its rules. The `Guidelines` class can parse the yamls. We can reach the guideline data via `getGuidelineRules` API endpoint that can return a list of `Rules`.
- Loading branch information
Showing
24 changed files
with
1,627 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# ------------------------------------------------------------------------- | ||
# | ||
# Part of the CodeChecker project, under the Apache License v2.0 with | ||
# LLVM Exceptions. See LICENSE for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ------------------------------------------------------------------------- | ||
import os | ||
from typing import DefaultDict, Dict, Iterable, List | ||
from collections import defaultdict | ||
|
||
import yaml | ||
|
||
|
||
class Guidelines: | ||
def __init__(self, guidelines_dir: str): | ||
if not os.path.isdir(guidelines_dir): | ||
raise NotADirectoryError( | ||
f'{guidelines_dir} is not a directory.') | ||
|
||
self.__guidelines_dir = guidelines_dir | ||
|
||
guideline_yaml_files = map( | ||
lambda f: os.path.join(guidelines_dir, f), | ||
os.listdir(guidelines_dir)) | ||
|
||
self.__all_rules = self.__union_guideline_files(guideline_yaml_files) | ||
|
||
def __union_guideline_files( | ||
self, | ||
guideline_files: Iterable[str] | ||
) -> Dict[str, DefaultDict[str, List[str]]]: | ||
""" | ||
This function creates a union object of the given guideline files. The | ||
resulting object maps guidelines to the collection of their rules. E.g.: | ||
{ | ||
"guideline1": [ | ||
{ | ||
"rule_id": ... | ||
"rule_url": ... | ||
"title": ... | ||
}, | ||
{ | ||
... | ||
} | ||
], | ||
"guideline2": [ | ||
... | ||
], | ||
} | ||
""" | ||
all_rules = defaultdict(list) | ||
|
||
for guideline_file in guideline_files: | ||
with open(guideline_file, "r") as gf: | ||
guideline_data = yaml.safe_load(gf) | ||
|
||
guideline_name = guideline_data.get("guideline") | ||
rules = guideline_data.get("rules") | ||
|
||
all_rules[guideline_name].extend(rules) | ||
|
||
return all_rules | ||
|
||
|
||
def rules_of_guideline( | ||
self, | ||
guidelineName: str, | ||
) -> List[Dict[str, str]]: | ||
""" | ||
Return the list of rules of a guideline. | ||
""" | ||
|
||
guideline_rules = self.__all_rules.get(guidelineName) | ||
|
||
return guideline_rules | ||
|
||
def all_guideline_rules(self) -> Dict[str, str]: | ||
return self.__all_rules |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-34 Bytes
(100%)
web/api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.