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: normalize path regex #44

Merged
merged 2 commits into from
Dec 9, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/python-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
repo=$(pwd)
# the workflow may change a bit after idf.py pull this in
cp ./pyclang/idf_extension.py $IDF_PATH/tools/idf_py_actions/temp_ext.py
# run install.sh again
bash $IDF_PATH/install.sh
# use idf python env
source $IDF_PATH/export.sh
# install this package
Expand Down
18 changes: 11 additions & 7 deletions pyclang/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ class Runner:
all related other params should be passed by ``__init__`` function to the Runner itself
"""

CLANG_TIDY_REGEX = re.compile(
# clang-tidy warnings format:
CLANG_TIDY_WARNING_REGEX = re.compile(
# FILE_PATH: LINENO: COL:SEVERITY:MSG [ERROR IDENTIFIER]
r'([\w/.\- ]+):(\d+):(\d+): (.+): (.+) \[([\w\-,.]+)]'
)

CLANG_TIDY_PATH_REGEX = re.compile(
# FILE_PATH: LINENO: COL:SEVERITY:
r'([\w/.\- ]+):(\d+):(\d+): (.+):'
)

WARN_FILENAME = 'warnings.txt'
COMPILE_COMMANDS_FILENAME = 'compile_commands.json'

Expand Down Expand Up @@ -380,7 +385,7 @@ def check_limits(self, *args):
with open(warn_file) as fr:
warnings_str = fr.read()
res = {check: [] for check in self.checks_limitations.keys()}
for path, line, col, severity, msg, code in self.CLANG_TIDY_REGEX.findall(
for path, line, col, severity, msg, code in self.CLANG_TIDY_WARNING_REGEX.findall(
warnings_str
):
if code not in res: # error identifier not in limit field
Expand Down Expand Up @@ -446,7 +451,7 @@ def make_html_report(self, *args):
warnings_str = fr.read()

res = []
for path, line, col, severity, msg, code in self.CLANG_TIDY_REGEX.findall(
for path, line, col, severity, msg, code in self.CLANG_TIDY_WARNING_REGEX.findall(
warnings_str
):
if self.ignore_clang_checks and any(
Expand Down Expand Up @@ -501,7 +506,7 @@ def normalize(self, *args):

with open(warn_file, 'w') as fw:
for line in warnings:
result = self.CLANG_TIDY_REGEX.match(line)
result = self.CLANG_TIDY_PATH_REGEX.match(line)
if result:
path = result.group(1)
norm_path = os.path.relpath(
Expand All @@ -510,8 +515,7 @@ def normalize(self, *args):
# if still have ../, then it's a system file, should not in idf path
if '../' in norm_path:
norm_path = '/' + _remove_prefix(norm_path, '../')
else:
norm_path = norm_path

line = line.replace(path, norm_path)
fw.write(line)
log_fs.write(f'Normalized file {warn_file}\n')
Loading