Skip to content

feat(lint): support clang-tidy across platforms - #296

Merged
XuehaiPan merged 3 commits into
metaopt:mainfrom
XuehaiPan:simplify-nolint
Sep 1, 2026
Merged

feat(lint): support clang-tidy across platforms#296
XuehaiPan merged 3 commits into
metaopt:mainfrom
XuehaiPan:simplify-nolint

Conversation

@XuehaiPan

Copy link
Copy Markdown
Member

Description

  • Use parenthesized NOLINT syntax and teach clang-format to preserve it.
  • Allow callers to select CLANG_TIDY, support both system and PyPI runner names, and preserve caller-provided CMake configuration arguments.
  • Add the macOS SDK sysroot to compile commands so the PyPI clang-tidy wheel can analyze Homebrew-built sources.
  • Re-audit suppressions code by code, including block suppressions and multi-code directives, while retaining aliases required by LLVM 22.

Motivation and Context

The PyPI clang-tidy wheel provides a consistent analyzer across Linux and macOS, but macOS analysis also needs the SDK sysroot in the compilation database. The previous suppressions included entries that no longer corresponded to emitted diagnostics and did not consistently cover renamed LLVM checks.

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Implemented Tasks

  • Support explicit system and PyPI clang-tidy binaries and runners.
  • Make macOS compile commands usable by the PyPI clang-tidy wheel.
  • Re-audit NOLINT suppressions individually across supported LLVM versions and platforms.

Checklist

  • I have read the CONTRIBUTION guide. (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly. (required for a bug fix or a new feature)
  • I have updated the documentation accordingly.
  • I have reformatted the code using make format. (required)
  • I have checked the code using make lint. (required)
  • I have ensured make test pass. (required)

Validation

  • make test: 93,901 passed, 26 skipped, 1 xfailed; 100% coverage.
  • make format: passed without changing the committed tree.
  • pre-commit run --all-files: passed.
  • PyPI LLVM 22.1.8 clang-tidy: no source diagnostics with Python 3.10 debug and Python 3.15 free-threaded debug prefixes on macOS.
  • LLVM 23.1 clang-tidy: passed on macOS and Ubuntu 26.04.
  • make lint CMAKE_CXX_STANDARD=17: all code checks passed, including clang-tidy and cpplint, but the target stopped in docstyle because Sphinx 9.1 reports two unresolved ClassVar forward-reference warnings for the unchanged PyTreeAccessor annotations.

clang-tidy interprets parenthesized check lists as scoped suppressions. Convert all existing NOLINT directives mechanically and update clang-format's CommentPragmas matcher for the new syntax.
Support both system and PyPI wheel runners, configure macOS compile commands with the SDK sysroot, and allow callers to select a clang-tidy binary without installing the wheel.

Address LLVM 23.1 diagnostics while retaining a narrow suppression for the unsafe PyObject const suggestion.
Remove suppressions that are no longer needed and retain only diagnostics reproduced by the supported clang-tidy versions. Keep LLVM 22 compatibility aliases where diagnostic names differ.
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1e2bc26) to head (862ef3e).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #296   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines         1623      1623           
  Branches       220       220           
=========================================
  Hits          1623      1623           
Flag Coverage Δ
unittests 100.00% <ø> (ø)
unittests-cp310-Linux 100.00% <ø> (ø)
unittests-cp310-Windows 100.00% <ø> (ø)
unittests-cp310-macOS 100.00% <ø> (ø)
unittests-cp311-Linux 100.00% <ø> (ø)
unittests-cp311-Windows 100.00% <ø> (ø)
unittests-cp311-macOS 100.00% <ø> (ø)
unittests-cp312-Linux 100.00% <ø> (ø)
unittests-cp312-Windows 100.00% <ø> (ø)
unittests-cp312-macOS 100.00% <ø> (ø)
unittests-cp313-Linux 100.00% <ø> (ø)
unittests-cp313-Windows 100.00% <ø> (ø)
unittests-cp313-macOS 100.00% <ø> (ø)
unittests-cp313t-Linux 100.00% <ø> (ø)
unittests-cp313t-Windows 100.00% <ø> (ø)
unittests-cp313t-macOS 100.00% <ø> (ø)
unittests-cp314-Linux 100.00% <ø> (ø)
unittests-cp314-Windows 100.00% <ø> (ø)
unittests-cp314-macOS 100.00% <ø> (ø)
unittests-cp314t-Linux 100.00% <ø> (ø)
unittests-cp314t-Windows 100.00% <ø> (ø)
unittests-cp314t-macOS 100.00% <ø> (ø)
unittests-cp315-Linux 100.00% <ø> (ø)
unittests-cp315-Windows 100.00% <ø> (ø)
unittests-cp315-macOS 100.00% <ø> (ø)
unittests-cp315t-Linux 100.00% <ø> (ø)
unittests-cp315t-Windows 100.00% <ø> (ø)
unittests-cp315t-macOS 100.00% <ø> (ø)
unittests-pp311-Linux 100.00% <ø> (ø)
unittests-pp311-Windows 100.00% <ø> (ø)
unittests-pp311-macOS 100.00% <ø> (ø)
unittests-pydebug 100.00% <ø> (ø)
unittests-pydebug-cp310d-Linux 100.00% <ø> (ø)
unittests-pydebug-cp310d-Windows 100.00% <ø> (ø)
unittests-pydebug-cp310d-macOS 100.00% <ø> (ø)
unittests-pydebug-cp311d-Linux 100.00% <ø> (ø)
unittests-pydebug-cp311d-Windows 100.00% <ø> (ø)
unittests-pydebug-cp311d-macOS 100.00% <ø> (ø)
unittests-pydebug-cp312d-Linux 100.00% <ø> (ø)
unittests-pydebug-cp312d-Windows 100.00% <ø> (ø)
unittests-pydebug-cp312d-macOS 100.00% <ø> (ø)
unittests-pydebug-cp313d-Linux 100.00% <ø> (ø)
unittests-pydebug-cp313d-Windows 100.00% <ø> (ø)
unittests-pydebug-cp313d-macOS 100.00% <ø> (ø)
unittests-pydebug-cp313td-Linux 100.00% <ø> (ø)
unittests-pydebug-cp313td-Windows 100.00% <ø> (ø)
unittests-pydebug-cp313td-macOS 100.00% <ø> (ø)
unittests-pydebug-cp314d-Linux 100.00% <ø> (ø)
unittests-pydebug-cp314d-Windows 100.00% <ø> (ø)
unittests-pydebug-cp314d-macOS 100.00% <ø> (ø)
unittests-pydebug-cp314td-Linux 100.00% <ø> (ø)
unittests-pydebug-cp314td-Windows 100.00% <ø> (ø)
unittests-pydebug-cp314td-macOS 100.00% <ø> (ø)
unittests-pydebug-cp315d-Linux 100.00% <ø> (ø)
unittests-pydebug-cp315d-Windows 100.00% <ø> (ø)
unittests-pydebug-cp315d-macOS 100.00% <ø> (ø)
unittests-pydebug-cp315td-Linux 100.00% <ø> (ø)
unittests-pydebug-cp315td-Windows 100.00% <ø> (ø)
unittests-pydebug-cp315td-macOS 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@XuehaiPan XuehaiPan self-assigned this Sep 1, 2026
@XuehaiPan XuehaiPan added enhancement New feature or request cxx Something related to the CXX source code dependencies Pull requests that update a dependency file labels Sep 1, 2026
@XuehaiPan
XuehaiPan merged commit 0e49b48 into metaopt:main Sep 1, 2026
11 of 180 checks passed
@XuehaiPan
XuehaiPan deleted the simplify-nolint branch September 1, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cxx Something related to the CXX source code dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant