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

Generating debug zip fails if the clang-tidy UseColor option is true #4411

Open
ArchieAtkinson opened this issue Jan 5, 2025 · 0 comments
Open

Comments

@ArchieAtkinson
Copy link
Contributor

ArchieAtkinson commented Jan 5, 2025

Describe the bug
When using CodeChecker to run clang-tidy, if the UseColor option is true and there are errors present, the setup to produce a debug zip fails due to the colours/bold in stdout. Output below (removed list of checks to reduce clutter):

[INFO 2025-01-05 17:30] - Enabled checkers:
clang-tidy: bugprone-assert-side-effect ....
[INFO 2025-01-05 17:30] - Starting static analysis ...
[ERROR 2025-01-05 17:30] - Analyzing main.cpp with clang-tidy  failed!
[ERROR 2025-01-05 17:30] - 
/home/user/west-workspace/notus/tests/button/src/main.cpp:64:9: error: variable name 'i' is too short, expected at least 3 characters [readability-identifier-length,-warnings-as-errors]
   64 |     int i = 0;
      |         ^
/home/user/west-workspace/notus/tests/button/src/main.cpp:65:5: error: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg,hicpp-vararg,-warnings-as-errors]
   65 |     printf("i%d", i);
      |     ^

[ERROR 2025-01-05 17:30] - 
104532 warnings generated.
Suppressed 104572 warnings (104529 in non-user code, 43 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings treated as errors

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/tu_collector/tu_collector.py", line 372, in add_sources_to_zip
    archive.getinfo(archive_path)
  File "/usr/lib/python3.10/zipfile.py", line 1443, in getinfo
    raise KeyError(
KeyError: "There is no item named 'sources-root/home/user/west-workspace/notus/tests/button/build/\\x1b[1m/home/user/west-workspace/notus/tests/button/src/main.cpp' in the archive"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/codechecker_analyzer/analysis_manager.py", line 638, in check
    handle_analysis_result(success=False)
  File "/usr/local/lib/python3.10/dist-packages/codechecker_analyzer/analysis_manager.py", line 614, in handle_analysis_result
    handle_failure(source_analyzer, rh,
  File "/usr/local/lib/python3.10/dist-packages/codechecker_analyzer/analysis_manager.py", line 331, in handle_failure
    handle_reproducer(source_analyzer, rh, zip_file, actions_map)
  File "/usr/local/lib/python3.10/dist-packages/codechecker_analyzer/analysis_manager.py", line 291, in handle_reproducer
    tu_collector.add_sources_to_zip(
  File "/usr/local/lib/python3.10/dist-packages/tu_collector/tu_collector.py", line 374, in add_sources_to_zip
    archive.write(f, archive_path, zipfile.ZIP_DEFLATED)
  File "/usr/lib/python3.10/zipfile.py", line 1741, in write
    zinfo = ZipInfo.from_file(filename, arcname,
  File "/usr/lib/python3.10/zipfile.py", line 504, in from_file
    st = os.stat(filename)
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/west-workspace/notus/tests/button/build/\x1b[1m/home/user/west-workspace/notus/tests/button/src/main.cpp'
[INFO 2025-01-05 17:30] - [1/3] clang-tidy analyzed button.cpp successfully.
[INFO 2025-01-05 17:30] - [2/3] clang-tidy analyzed button_error.cpp successfully.
[INFO 2025-01-05 17:30] - ----==== Summary ====----
[INFO 2025-01-05 17:30] - Successfully analyzed
[INFO 2025-01-05 17:30] -   clang-tidy: 2
[INFO 2025-01-05 17:30] - Failed to analyze
[INFO 2025-01-05 17:30] -   clang-tidy: 1
[INFO 2025-01-05 17:30] - Reanalyzed compilation commands: 3
[INFO 2025-01-05 17:30] - Total analyzed compilation commands: 3
[INFO 2025-01-05 17:30] - Skipped compilation commands: 80
[INFO 2025-01-05 17:30] - ----=================----
[INFO 2025-01-05 17:30] - Analysis finished.
[INFO 2025-01-05 17:30] - To view results in the terminal use the "CodeChecker parse" command.
[INFO 2025-01-05 17:30] - To store results use the "CodeChecker store" command.
[INFO 2025-01-05 17:30] - See --help and the user guide for further options about parsing and storing the reports.
[INFO 2025-01-05 17:30] - ----=================----
[INFO 2025-01-05 17:30] - Analysis length: 9.457396984100342 sec.

CodeChecker version
6.23.1

To Reproduce
Run CodeChecker analyze --analyzers=clang-tidy --analyzer-config=clang-tidy:take-config-from-directory=true
Where the .clang-tidy contains UseColor: true.

This causes the clang-tidy output to be in bold, captured by the handle_reproducer in analysis_manager.py.

Expected behaviour
It not to fail to zip the files while UseColor is enabled

Desktop (please complete the following information)

  • OS: Linux (WSL2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant