Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake-format merges two comment lines and breaks cmake-lint disable comment #331

Open
berthin opened this issue Oct 4, 2023 · 1 comment

Comments

@berthin
Copy link

berthin commented Oct 4, 2023

Hi,

I am running cmake-format and cmake-lint as part of my pre-commit check with the following snippet:

    # Loop through submodules
    # cmake-lint: disable=E1120      
    foreach(IDX RANGE ${_SUBMODULES_COUNT})

cmake-lint is happy about that, but cmake-format sees that it can merge the two lines because they are comments, doesn't recognize that one is actual an internal cmake-* instruction, and joins them into

    # Loop through submodules cmake-lint: disable=E1120      
    foreach(IDX RANGE ${_SUBMODULES_COUNT})

and now cmake-lint complains about E1120 because that rule is not disabled anymore.

Anyway to workaround this issue? I looked at the cmake-format options but didn't find an "ignore_comment_regex" or similar option that I can use to tell cmake-format to ignore the formatting if it finds a comment that matches a regex.

I also think this is a bug. "cmake-lint" is an internal instruction from the same family tools as cmake-format, why would it not understand that?

@berthin
Copy link
Author

berthin commented Oct 4, 2023

The workaround I use is

    # cmake-format: off
    # cmake-lint: disable=E1120
    # cmake-format: on

but this is kind of ugly to be honest

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

No branches or pull requests

1 participant