Repository navigation
[beman-tidy] Implement cmake.avoid_passthroughs check (#71) - #344
Draft
neatudarius wants to merge 5 commits into
Draft
neatudarius wants to merge 5 commits into
neatudarius wants to merge 5 commits into
Conversation
neatudarius
force-pushed
the
implement/issue-71-cmake-avoid-passthroughs
branch
3 times, most recently
from
July 15, 2026 23:58
318644f to
8d0ed96
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds the cmake.avoid_passthroughs Beman Standard check to detect shallow add_subdirectory(...) passthrough CMakeLists patterns, along with test coverage and new test fixtures.
Changes:
- Implemented
CMakeAvoidPassthroughsCheck(dry-run/check mode) and registered it undercmake.avoid_passthroughs. - Added pytest coverage for valid/invalid scenarios plus new invalid CMakeLists fixtures.
- Added
get_cmake_files()utility for discoveringCMakeLists.txtand*.cmakefiles in a repo.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/lib/checks/beman_standard/cmake/test_cmake.py | Adds tests for the new cmake.avoid_passthroughs check (valid/invalid + skipped fix test). |
| tests/lib/checks/beman_standard/cmake/data/invalid/invalid-avoid_passthroughs-v1.txt | New invalid fixture: shallow add_subdirectory(src). |
| tests/lib/checks/beman_standard/cmake/data/invalid/invalid-avoid_passthroughs-v2.txt | New invalid fixture: shallow add_subdirectory(beman). |
| tests/lib/checks/beman_standard/cmake/data/invalid/invalid-avoid_passthroughs-v3.txt | New invalid fixture: “passthrough-only” file with a shallow add_subdirectory(...). |
| beman_tidy/lib/utils/file.py | Adds get_cmake_files() helper to enumerate CMake-related files. |
| beman_tidy/lib/checks/beman_standard/cmake.py | Implements and registers CMakeAvoidPassthroughsCheck. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+371
to
+379
| def fix(self): | ||
| self.log( | ||
| "Please replace shallow add_subdirectory passthroughs with direct paths " | ||
| "such as add_subdirectory(include/beman/<short_name>) or " | ||
| "add_subdirectory(src/beman/<short_name>). " | ||
| "See https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md#cmakeavoid_passthroughs " | ||
| "for more information." | ||
| ) | ||
| return False |
Member
Author
neatudarius
force-pushed
the
implement/issue-71-cmake-avoid-passthroughs
branch
6 times, most recently
from
July 16, 2026 06:38
dd657ed to
d5c76d2
Compare
neatudarius
force-pushed
the
implement/issue-71-cmake-avoid-passthroughs
branch
from
July 16, 2026 06:43
d5c76d2 to
070552d
Compare
…ake-avoid-passthroughs
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The CMake checks falsely flag substantive src directories while missing forwarding-only descendant CMakeLists.txt files because they inspect only the root file.
3 open issues
1 resolved since last review
Review effort: Balanced
Comment on lines
+495
to
+497
| arg = item.args[0].value.strip('"') | ||
| if arg in ("src", "beman"): | ||
| return True |
| return add_subdirectory_count == 1 and has_shallow_add_subdirectory | ||
|
|
||
| def check(self): | ||
| ast = list(self.get_cmake_parse_raw()) |
Also match CMake command names case-insensitively and normalize paths like ./src/.
…ake-avoid-passthroughs
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Implements #71