Skip to content

Commit 9a4bec3

Browse files
committed
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 <[email protected]>
1 parent e6ca8d9 commit 9a4bec3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

scripts/ci/guideline_check.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@
1111
if "ZEPHYR_BASE" not in os.environ:
1212
exit("$ZEPHYR_BASE environment variable undefined.")
1313

14-
coccinelle_scripts = ["/scripts/coccinelle/reserved_names.cocci",
14+
RESERVED_NAMES_SCRIPT = "/scripts/coccinelle/reserved_names.cocci"
15+
16+
coccinelle_scripts = [RESERVED_NAMES_SCRIPT,
1517
"/scripts/coccinelle/same_identifier.cocci",
1618
#"/scripts/coccinelle/identifier_length.cocci",
1719
]
1820

21+
coccinelle_reserved_names_exclude_regex = [
22+
r"lib/libc/.*",
23+
r"lib/posix/.*",
24+
r"include/zephyr/posix/.*",
25+
]
1926

2027
def parse_coccinelle(contents: str, violations: dict):
2128
reg = re.compile("([a-zA-Z0-9_/]*\\.[ch]:[0-9]*)(:[0-9\\-]*: )(.*)")
@@ -69,7 +76,18 @@ def main():
6976
continue
7077

7178
for script in coccinelle_scripts:
72-
script_path = os.getenv("ZEPHYR_BASE") + "/" + script
79+
80+
skip_reserved_names = False
81+
if script == RESERVED_NAMES_SCRIPT:
82+
for path in coccinelle_reserved_names_exclude_regex:
83+
if re.match(path, f.path):
84+
skip_reserved_names = True
85+
break
86+
87+
if skip_reserved_names:
88+
continue
89+
90+
script_path =zephyr_base + "/" + script
7391
print(f"Running {script} on {f.path}")
7492
try:
7593
cocci = sh.coccicheck(

0 commit comments

Comments
 (0)