Skip to content

Implement cmake.default check with fix-inplace support - #372

Closed
neatudarius with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-review-comment-343
Closed

Implement cmake.default check with fix-inplace support#372
neatudarius with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-review-comment-343

Conversation

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

PR #343 introduced cmake.default with check() only — fix() was a stub returning False, and the fix-inplace test was skipped. This adds a working fix() implementation and an active test.

Changes

  • cmake.py

    • Added CMakeDefaultCheck with check() and fix()
    • check() fails if the main library target is inside an if() block or guarded by an option() defaulting to OFF
    • fix() uses cmake_parser AST span indices to extract add_library commands from the conditional block, replace the entire if()/endif() with unconditional targets, and remove the guarding option() if present; falls back to a log+False when the if() 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 behind option(... OFF) + if() guard
    • invalid/invalid-default-v2.txt — library inside if(PROJECT_IS_TOP_LEVEL)
  • test_cmake.py

    • Imports CMakeDefaultCheck and run_fix_inplace_for_each_file_path
    • Adds valid/invalid check tests and an active (non-skipped) test__cmake_default__fix_inplace that verifies the file passes check() after fix()

Example fix behaviour

# Before (invalid-default-v1): library behind OFF option
option(BEMAN_EXEMPLAR_BUILD_LIBRARY "..." OFF)
if(BEMAN_EXEMPLAR_BUILD_LIBRARY)
    add_library(beman.exemplar INTERFACE)
    add_library(beman::exemplar ALIAS beman.exemplar)
endif()

# After fix(): option and if/endif removed, library unconditional
add_library(beman.exemplar INTERFACE)
add_library(beman::exemplar ALIAS beman.exemplar)

Copilot AI review requested due to automatic review settings July 26, 2026 16: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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI review requested due to automatic review settings July 26, 2026 16:53

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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

…k restructuring, document blank line cleanup
Copilot AI review requested due to automatic review settings July 26, 2026 16:54

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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI review requested due to automatic review settings July 26, 2026 16:55

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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

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
Copilot AI requested a review from neatudarius July 26, 2026 16:56
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

Successfully merging this pull request may close these issues.

3 participants