Implement cmake.default check with fix-inplace support - #372
Closed
neatudarius with Copilot wants to merge 4 commits into
Closed
Implement cmake.default check with fix-inplace support#372neatudarius with Copilot wants to merge 4 commits into
neatudarius with Copilot wants to merge 4 commits into
Conversation
…k restructuring, document blank line cleanup
Copilot
AI
changed the title
[WIP] Fix code as per review comment for PR 343
Implement cmake.default check with fix-inplace support
Jul 26, 2026
Copilot stopped work on behalf of
neatudarius due to an error
July 26, 2026 16:56
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.
PR #343 introduced
cmake.defaultwithcheck()only —fix()was a stub returningFalse, and the fix-inplace test was skipped. This adds a workingfix()implementation and an active test.Changes
cmake.pyCMakeDefaultCheckwithcheck()andfix()check()fails if the main library target is inside anif()block or guarded by anoption()defaulting toOFFfix()uses cmake_parser ASTspanindices to extractadd_librarycommands from the conditional block, replace the entireif()/endif()with unconditional targets, and remove the guardingoption()if present; falls back to a log+Falsewhen theif()block also contains non-library commands (unsafe to restructure automatically)Test data (
tests/lib/checks/beman_standard/cmake/data/)valid/valid-default-v1.txt— unconditional library target (passes)invalid/invalid-default-v1.txt— library behindoption(... OFF)+if()guardinvalid/invalid-default-v2.txt— library insideif(PROJECT_IS_TOP_LEVEL)test_cmake.pyCMakeDefaultCheckandrun_fix_inplace_for_each_file_pathtest__cmake_default__fix_inplacethat verifies the file passescheck()afterfix()Example fix behaviour