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

[ci] fix CMakeLint errors related to function naming case #4794

Merged
merged 9 commits into from
Nov 14, 2021
Merged

Conversation

StrikerRUS
Copy link
Collaborator

Contributes to #4602.

Use lower case for all functions to fix all readability/mixedcase errors.

There are false alerts for readability/wonkycas in some built-in CMake functions, e.g.

FetchContent_Declare(

FetchContent_MakeAvailable(googletest)

https://cmake.org/cmake/help/latest/module/FetchContent.html

So the option only is to not check readability/wonkycase type of errors. Because there is no NOLINT directive in the cmakelint package like it is in the cpplint package 🙁 .

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

There are false alerts for readability/wonkycas in some built-in CMake

@StrikerRUS I don't think we need to filter out the readability/wonkycase warnings.

I think the mixed-case commands you mentioned can be lower-cased. I tried that tonight and was able to run the tests successfully.

# lowercase commands
sed -i.bak -e "s/FetchContent_Declare/fetchcontent_declare/" CMakeLists.txt
sed -i.bak -e "s/FetchContent_MakeAvailable/fetchcontent_makeavailable/" CMakeLists.txt

# run tests
rm -rf build/
mkdir build/
cmake -DBUILD_CPP_TEST=ON -DUSE_OPENMP=OFF -DUSE_DEBUG=ON ..
make testlightgbm -j4
./../testlightgbm

That's consistent with https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#command-invocations, which says

Command names are case-insensitive

@StrikerRUS
Copy link
Collaborator Author

Hmmm, thanks for clarifying that those commands can be lower-cased. But in the official docs they are mixed-cased. Don't you think we should stick to the official (which I personally consider as a recommended) CMake naming style but not to cmakelint one?

@jameslamb
Copy link
Collaborator

Don't you think we should stick to the official (which I personally consider as a recommended) CMake naming style but not to cmakelint one

Personally, I'd prefer to use the lower-cased one so cmakelint can continue to do the review work for us of telling contributors to lowercase commands.

Otherwise, we'll have to write comments like "can you please change OPTION() to option() for consistency", "can you please change ADD_DEFINITIONS() to add_definitions()", etc.

@StrikerRUS
Copy link
Collaborator Author

Otherwise, we'll have to write comments like "can you please change OPTION() to option() for consistency", "can you please change ADD_DEFINITIONS() to add_definitions()", etc.

These style issues will produce readability/mixedcase error. So we won't have say anything.
cmakelint will stop catching something like OptIoN() or add_DEFINITIONS(). Do you think this is a common problem we'll face?

@jameslamb
Copy link
Collaborator

ohhhhh I understand, yeah ok I am ok with filtering out readability/wonkycase then. Thanks for talking through it with me.

@jameslamb jameslamb self-requested a review November 14, 2021 00:17
@jameslamb
Copy link
Collaborator

Nice work! Just 3 warnings from cmakelint remaining after this!

https://github.com/microsoft/LightGBM/runs/4201144410?check_suite_focus=true

@jameslamb jameslamb merged commit 144036f into master Nov 14, 2021
@jameslamb jameslamb deleted the cmakelint branch November 14, 2021 01:38
@StrikerRUS StrikerRUS mentioned this pull request Jan 6, 2022
13 tasks
@jameslamb jameslamb mentioned this pull request Oct 7, 2022
40 tasks
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants