Skip to content

[beman-tidy] Implement cmake.avoid_passthroughs check (#71) - #344

Draft
neatudarius wants to merge 5 commits into
bemanproject:mainfrom
neatudarius:implement/issue-71-cmake-avoid-passthroughs
Draft

neatudarius wants to merge 5 commits into
bemanproject:mainfrom
neatudarius:implement/issue-71-cmake-avoid-passthroughs

Conversation

@neatudarius

@neatudarius neatudarius commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Implements #71

@neatudarius neatudarius changed the title Implement cmake.avoid_passthroughs check (#71) [beman-tidy]Implement cmake.avoid_passthroughs check (#71) Jul 15, 2026
@neatudarius neatudarius changed the title [beman-tidy]Implement cmake.avoid_passthroughs check (#71) [beman-tidy] Implement cmake.avoid_passthroughs check (#71) Jul 15, 2026
@neatudarius
neatudarius force-pushed the implement/issue-71-cmake-avoid-passthroughs branch 3 times, most recently from 318644f to 8d0ed96 Compare July 15, 2026 23:58
@neatudarius
neatudarius requested a review from Copilot July 16, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 under cmake.avoid_passthroughs.
  • Added pytest coverage for valid/invalid scenarios plus new invalid CMakeLists fixtures.
  • Added get_cmake_files() utility for discovering CMakeLists.txt and *.cmake files 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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changed: no cmake.* check implements fix-inplace, and moving CMake logic between directories isn't a safe automatic edit. The PR says 'Implements #71' rather than closing it, so the fix-inplace item stays open on #71.

@neatudarius
neatudarius force-pushed the implement/issue-71-cmake-avoid-passthroughs branch 6 times, most recently from dd657ed to d5c76d2 Compare July 16, 2026 06:38
@neatudarius
neatudarius force-pushed the implement/issue-71-cmake-avoid-passthroughs branch from d5c76d2 to 070552d Compare July 16, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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/.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants