Skip to content

Commit

Permalink
[ci] Run cmakelint at CI and fix some errors (#4617)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS authored Sep 22, 2021
1 parent b5557b6 commit c3b60c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if [[ $TASK == "lint" ]]; then
libxml2 \
"r-xfun>=0.19" \
"r-lintr>=2.0"
pip install --user cpplint isort mypy
pip install --user cmakelint cpplint isort mypy
echo "Linting Python code"
pycodestyle --ignore=E501,W503 --exclude=./.nuget,./external_libs . || exit -1
pydocstyle --convention=numpy --add-ignore=D105 --match-dir="^(?!^external_libs|test|example).*" --match="(?!^test_|setup).*\.py" . || exit -1
Expand All @@ -81,6 +81,8 @@ if [[ $TASK == "lint" ]]; then
Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1
echo "Linting C++ code"
cpplint --filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length --recursive ./src ./include ./R-package ./swig ./tests || exit -1
cmake_files=$(find . -name CMakeLists.txt -o -path "*/cmake/*.cmake")
cmakelint --linelength=120 ${cmake_files} || true
exit 0
fi

Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PROJECT(lightgbm LANGUAGES C CXX)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")

#-- Sanitizer
if (USE_SANITIZER)
if(USE_SANITIZER)
if(MSVC)
message(FATAL_ERROR "Sanitizers are not supported with MSVC.")
endif(MSVC)
Expand Down Expand Up @@ -144,11 +144,11 @@ if(USE_GPU)
find_package(OpenCL REQUIRED)
include_directories(${OpenCL_INCLUDE_DIRS})
MESSAGE(STATUS "OpenCL include directory: " ${OpenCL_INCLUDE_DIRS})
if (WIN32)
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
endif()
find_package(Boost 1.56.0 COMPONENTS filesystem system REQUIRED)
if (WIN32)
if(WIN32)
# disable autolinking in boost
add_definitions(-DBOOST_ALL_NO_LIB)
endif()
Expand Down Expand Up @@ -194,7 +194,7 @@ if(USE_CUDA)
message(STATUS "CMAKE_CUDA_FLAGS: ${CMAKE_CUDA_FLAGS}")

ADD_DEFINITIONS(-DUSE_CUDA)
if (NOT DEFINED CMAKE_CUDA_STANDARD)
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()
Expand Down Expand Up @@ -230,7 +230,7 @@ if(USE_CUDA)
)
endfunction()

foreach (hsize _16_64_256)
foreach(hsize _16_64_256)
add_histogram("${hsize}" "_sp_const" "True" "1" "${BASE_DEFINES}")
add_histogram("${hsize}" "_sp" "True" "0" "${BASE_DEFINES}")
add_histogram("${hsize}" "-allfeats_sp_const" "False" "1" "${ALLFEATS_DEFINES}")
Expand Down Expand Up @@ -364,7 +364,7 @@ if(__BUILD_FOR_R)
list(APPEND SOURCES "src/lightgbm_R.cpp")
endif(__BUILD_FOR_R)

if (BUILD_STATIC_LIB)
if(BUILD_STATIC_LIB)
add_library(_lightgbm STATIC ${SOURCES})
else()
add_library(_lightgbm SHARED ${SOURCES})
Expand Down
6 changes: 3 additions & 3 deletions cmake/modules/FindLibR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ elseif(WIN32)
endif()


if (NOT LIBR_EXECUTABLE)
if(NOT LIBR_EXECUTABLE)
find_program(
LIBR_EXECUTABLE
NAMES R R.exe
Expand All @@ -99,7 +99,7 @@ if (NOT LIBR_EXECUTABLE)
endif()

# Find R executable unless it has been provided directly or already found
if (NOT LIBR_EXECUTABLE)
if(NOT LIBR_EXECUTABLE)
if(APPLE)

find_library(LIBR_LIBRARIES R)
Expand Down Expand Up @@ -193,7 +193,7 @@ find_library(

# starting from CMake 3.17, find_library() will not find .dll files by default
# https://cmake.org/cmake/help/v3.17/release/3.17.html#other-changes
if (WIN32 AND NOT LIBR_CORE_LIBRARY)
if(WIN32 AND NOT LIBR_CORE_LIBRARY)
find_file(
LIBR_CORE_LIBRARY
NAME R.dll
Expand Down

0 comments on commit c3b60c2

Please sign in to comment.