From 8b6ba7e349202bb36a49395071b4abc3ed2b68ea Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Wed, 18 Dec 2024 02:34:14 +0300 Subject: [PATCH] Update lint-cpp.sh --- .ci/lint-cpp.sh | 108 +++++++++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/.ci/lint-cpp.sh b/.ci/lint-cpp.sh index 2bd3e487c40b..8a3348ce254a 100755 --- a/.ci/lint-cpp.sh +++ b/.ci/lint-cpp.sh @@ -2,54 +2,66 @@ set -e -E -u -o pipefail -echo "running cpplint" -cpplint \ - --filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length \ - --recursive ./src ./include ./R-package ./swig ./tests \ -|| exit 1 -echo "done running cpplint" +echo "running clang-tidy" +cmake \ + -B build \ + -S . \ + -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-checks=-*,misc-include-cleaner" -echo "running cmakelint" -find \ - . \ - -type f \ - \( -name CMakeLists.txt -o -path "./cmake/*.cmake" \) \ - -not -path './external_libs/*' \ - -exec cmakelint \ - --linelength=120 \ - --filter=-convention/filename,-package/stdargs,-readability/wonkycase \ - {} \+ \ -|| exit 1 -echo "done running cmakelint" +cmake \ + --build build \ + --target _lightgbm \ + 2>&1 +echo "done running clang-tidy" -echo "checking that all OpenMP pragmas specify num_threads()" -get_omp_pragmas_without_num_threads() { - grep \ - -n \ - -R \ - --include='*.c' \ - --include='*.cc' \ - --include='*.cpp' \ - --include='*.h' \ - --include='*.hpp' \ - 'pragma omp parallel' \ - | grep -v ' num_threads' -} +# echo "running cpplint" +# cpplint \ +# --filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length \ +# --recursive ./src ./include ./R-package ./swig ./tests \ +# || exit 1 +# echo "done running cpplint" -# 'grep' returns a non-0 exit code if 0 lines were found. -# Turning off '-e -o pipefail' options here so that bash doesn't -# consider this a failure and stop execution of the script. -# -# ref: https://www.gnu.org/software/grep/manual/html_node/Exit-Status.html -set +e +o pipefail -PROBLEMATIC_LINES=$( - get_omp_pragmas_without_num_threads -) -set -e -o pipefail -if test "${PROBLEMATIC_LINES}" != ""; then - get_omp_pragmas_without_num_threads - echo "Found '#pragma omp parallel' not using explicit num_threads() configuration. Fix those." - echo "For details, see https://www.openmp.org/spec-html/5.0/openmpse14.html#x54-800002.6" - exit 1 -fi -echo "done checking OpenMP pragmas" +# echo "running cmakelint" +# find \ +# . \ +# -type f \ +# \( -name CMakeLists.txt -o -path "./cmake/*.cmake" \) \ +# -not -path './external_libs/*' \ +# -exec cmakelint \ +# --linelength=120 \ +# --filter=-convention/filename,-package/stdargs,-readability/wonkycase \ +# {} \+ \ +# || exit 1 +# echo "done running cmakelint" + +# echo "checking that all OpenMP pragmas specify num_threads()" +# get_omp_pragmas_without_num_threads() { +# grep \ +# -n \ +# -R \ +# --include='*.c' \ +# --include='*.cc' \ +# --include='*.cpp' \ +# --include='*.h' \ +# --include='*.hpp' \ +# 'pragma omp parallel' \ +# | grep -v ' num_threads' +# } + +# # 'grep' returns a non-0 exit code if 0 lines were found. +# # Turning off '-e -o pipefail' options here so that bash doesn't +# # consider this a failure and stop execution of the script. +# # +# # ref: https://www.gnu.org/software/grep/manual/html_node/Exit-Status.html +# set +e +o pipefail +# PROBLEMATIC_LINES=$( +# get_omp_pragmas_without_num_threads +# ) +# set -e -o pipefail +# if test "${PROBLEMATIC_LINES}" != ""; then +# get_omp_pragmas_without_num_threads +# echo "Found '#pragma omp parallel' not using explicit num_threads() configuration. Fix those." +# echo "For details, see https://www.openmp.org/spec-html/5.0/openmpse14.html#x54-800002.6" +# exit 1 +# fi +# echo "done checking OpenMP pragmas"