scripts: ci: guideline_check: mitigate excessive false positives
In order to reduce excessive false positives for Coding Guidelines checks in CI, maintain a list of paths that are marked "safe" for reserved names to be implemented or declared. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
parent
ad3e941ad3
commit
1c28ded7c3
1 changed files with 20 additions and 2 deletions
|
@ -11,11 +11,18 @@ from unidiff import PatchSet
|
|||
if "ZEPHYR_BASE" not in os.environ:
|
||||
exit("$ZEPHYR_BASE environment variable undefined.")
|
||||
|
||||
coccinelle_scripts = ["/scripts/coccinelle/reserved_names.cocci",
|
||||
RESERVED_NAMES_SCRIPT = "/scripts/coccinelle/reserved_names.cocci"
|
||||
|
||||
coccinelle_scripts = [RESERVED_NAMES_SCRIPT,
|
||||
"/scripts/coccinelle/same_identifier.cocci",
|
||||
#"/scripts/coccinelle/identifier_length.cocci",
|
||||
]
|
||||
|
||||
coccinelle_reserved_names_exclude_regex = [
|
||||
r"lib/libc/.*",
|
||||
r"lib/posix/.*",
|
||||
r"include/zephyr/posix/.*",
|
||||
]
|
||||
|
||||
def parse_coccinelle(contents: str, violations: dict):
|
||||
reg = re.compile("([a-zA-Z0-9_/]*\\.[ch]:[0-9]*)(:[0-9\\-]*: )(.*)")
|
||||
|
@ -69,7 +76,18 @@ def main():
|
|||
continue
|
||||
|
||||
for script in coccinelle_scripts:
|
||||
script_path = os.getenv("ZEPHYR_BASE") + "/" + script
|
||||
|
||||
skip_reserved_names = False
|
||||
if script == RESERVED_NAMES_SCRIPT:
|
||||
for path in coccinelle_reserved_names_exclude_regex:
|
||||
if re.match(path, f.path):
|
||||
skip_reserved_names = True
|
||||
break
|
||||
|
||||
if skip_reserved_names:
|
||||
continue
|
||||
|
||||
script_path =zephyr_base + "/" + script
|
||||
print(f"Running {script} on {f.path}")
|
||||
try:
|
||||
cocci = sh.coccicheck(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue