Skip to content

Conversation

@jameslamb
Copy link
Collaborator

Contributes to #6949 and #6901, by moving more logic out of test.sh.

Proposes moving C++ linting into pre-commit:

  • cpplint
  • manual check with grep for OpenMP pragmas calling the LightGBM-specific thread-control macros

Also proposes upgrading from cpplint 1.6.0 to 2.0.2 (the latest version), and fixes one type of formatting warning it raises.

Notes for Reviewers

Why also upgrade cpplint?

Looks like there was a cpplint 2.0 release about a year ago: https://github.com/cpplint/cpplint/releases/tag/2.0.0

But we haven't been taking advantage of all those new checks here, because we install cpplint with conda and the conda-forge feedstock is not being actively maintained. See all the unmerged PRs here: https://github.com/conda-forge/cpplint-feedstock/pulls

This new cpplint version suggests hundreds of changes, in roughly 4 different categories:

1. "Controlled statements inside brackets of while clause should be on a separate line [whitespace/newline]"
# bad
if (i > 5) { continue; }

# good
if (i > 5) {
  continue;
}
2. "Add `#include ` for `pair<>` [build/include_what_you_use]`

This is implementing some degree of include-what-you-use, to ensure headers aren't relying on transitive includes! (ref: #6284).

3. "Do not indent within a namespace. [whitespace/indent_namespace]"
# bad
namespace LightGBM {

class Dataset;

}

# good
namespace LightGBM {

class Dataset;

}
4. "Using C-style cast. Use `static_cast(...)` instead [readability/casting]"
# bad
new boost::compute::vector<Feature4>((uint64_t)num_dense_feature4_ * num_data_, ctx_)

# good
new boost::compute::vector<Feature4>(static_cast<uint64_t>(num_dense_feature4_) * num_data_, ctx_)

Proposing:

  • whitespace/newline: fix in this PR
  • build/include_what_you_use: fix in followup PRs
  • whitespace/indent_namespace: ignore indefinitely
  • readability/casting: fix in this PR
full list of 333 warnings (click me)
include/LightGBM/utils/text_reader.h:127:  Controlled statements inside brackets of while clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/text_reader.h:287:  Controlled statements inside brackets of while clause should be on a separate line  [whitespace/newline] [5]
src/boosting/gbdt_model_text.cpp:386:  Add #include <utility> for pair<>  [build/include_what_you_use] [4]
src/boosting/gbdt_model_text.cpp:427:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/boosting/gbdt_model_text.cpp:631:  Add #include <algorithm> for min  [build/include_what_you_use] [4]
src/io/bin.cpp:23:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:26:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:29:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:45:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:47:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:49:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:51:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:52:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:54:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:76:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:78:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:134:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/bin.cpp:155:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:157:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:240:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:242:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:298:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:300:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:309:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:311:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:506:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:508:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:532:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:534:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:564:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:566:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:581:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:583:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:598:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:600:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:601:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:602:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:603:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:605:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:606:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:607:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:609:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:610:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:611:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:613:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:623:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:625:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:633:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:635:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:644:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:646:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:665:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:667:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:706:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:708:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:709:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:718:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:720:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:721:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:730:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:732:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:733:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:742:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:744:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:745:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:754:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:756:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:757:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:765:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:767:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:768:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:776:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:778:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:779:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:787:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:789:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:790:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:798:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:800:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:801:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:812:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:814:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:815:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:826:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:828:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:829:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:840:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:842:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:843:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:851:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:853:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:854:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:862:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:864:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:865:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:873:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:875:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:876:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:877:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:890:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:892:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:893:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:907:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:909:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:910:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:924:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:926:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:927:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:940:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:942:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:943:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:956:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:958:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:959:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:972:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:974:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:975:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:988:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:990:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:991:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1004:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1006:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1007:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1020:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1022:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1023:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1036:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1038:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1039:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1052:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1054:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1055:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1068:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:1070:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/bin.cpp:683:  Add #include <limits> for numeric_limits<>  [build/include_what_you_use] [4]
src/io/bin.cpp:832:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/config_auto.cpp:184:  Add #include <unordered_set> for unordered_set<>  [build/include_what_you_use] [4]
src/io/config_auto.cpp:793:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/config_auto.cpp:939:  Add #include <string> for string  [build/include_what_you_use] [4]
src/io/config_auto.cpp:939:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/io/cuda/cuda_row_data.cpp:412:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/dataset.cpp:26:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/dataset.cpp:28:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/dataset.cpp:319:  Add #include <utility> for swap  [build/include_what_you_use] [4]
src/io/dataset.cpp:654:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/io/dataset.cpp:673:  Add #include <algorithm> for max  [build/include_what_you_use] [4]
src/io/dataset.cpp:1700:  Add #include <unordered_set> for unordered_set<>  [build/include_what_you_use] [4]
src/io/dataset.cpp:1739:  Add #include <string> for string  [build/include_what_you_use] [4]
src/io/dataset.cpp:1783:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/train_share_states.cpp:177:  Add #include <algorithm> for min  [build/include_what_you_use] [4]
src/io/train_share_states.cpp:478:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/io/train_share_states.cpp:518:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/tree.cpp:698:  Add #include <string> for string  [build/include_what_you_use] [4]
src/io/tree.cpp:833:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/tree.cpp:980:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/io/tree.cpp:987:  Add #include <algorithm> for copy  [build/include_what_you_use] [4]
src/network/linker_topo.cpp:71:  Controlled statements inside brackets of while clause should be on a separate line  [whitespace/newline] [5]
src/objective/rank_objective.hpp:209:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/objective/rank_objective.hpp:211:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/objective/rank_objective.hpp:213:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/data_parallel_tree_learner.cpp:15:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/treelearner/data_parallel_tree_learner.cpp:131:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/data_parallel_tree_learner.cpp:387:  Add #include <algorithm> for min  [build/include_what_you_use] [4]
src/boosting/prediction_early_stop.cpp:40:  Add #include <functional> for greater<>  [build/include_what_you_use] [4]
src/boosting/prediction_early_stop.cpp:75:  Add #include <string> for string  [build/include_what_you_use] [4]
src/io/cuda/cuda_column_data.cpp:105:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/json11.cpp:276:  Add #include <memory> for make_shared<>  [build/include_what_you_use] [4]
src/io/json11.cpp:692:  Add #include <utility> for move  [build/include_what_you_use] [4]
src/io/json11.cpp:748:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/json11.cpp:765:  Add #include <string> for string  [build/include_what_you_use] [4]
src/metric/xentropy_metric.hpp:35:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/metric/xentropy_metric.hpp:50:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/metric/xentropy_metric.hpp:53:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/metric/xentropy_metric.hpp:55:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/metric/xentropy_metric.hpp:60:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/metric/xentropy_metric.hpp:66:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/network/linkers_socket.cpp:51:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/treelearner/cuda/cuda_best_split_finder.cu:2181:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/treelearner/cuda/cuda_histogram_constructor.cpp:44:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/treelearner/gpu_tree_learner.cpp:248:  Using C-style cast.  Use static_cast<uint64_t>(...) instead  [readability/casting] [4]
src/treelearner/gpu_tree_learner.cpp:430:  Using C-style cast.  Use static_cast<uint64_t>(...) instead  [readability/casting] [4]
src/treelearner/gpu_tree_learner.cpp:506:  Using C-style cast.  Use static_cast<uint64_t>(...) instead  [readability/casting] [4]
src/treelearner/gpu_tree_learner.cpp:1092:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/gpu_tree_learner.cpp:309:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/treelearner/gpu_tree_learner.cpp:546:  Add #include <string> for string  [build/include_what_you_use] [4]
src/treelearner/gpu_tree_learner.cpp:626:  Add #include <iostream> for cerr  [build/include_what_you_use] [4]
src/treelearner/gpu_tree_learner.cpp:975:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/treelearner/gpu_tree_learner.cpp:1102:  Add #include <cstdio> for printf  [build/include_what_you_use] [4]
tests/cpp_tests/test_byte_buffer.cpp:15:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
include/LightGBM/meta.h:86:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/io/parser.cpp:180:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/metric/dcg_calculator.cpp:34:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/metric/dcg_calculator.cpp:63:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/metric/dcg_calculator.cpp:93:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/metric/dcg_calculator.cpp:124:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/network/linkers_mpi.cpp:55:  Add #include <iostream> for cerr  [build/include_what_you_use] [4]
src/treelearner/col_sampler.hpp:103:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/feature_parallel_tree_learner.cpp:15:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/treelearner/feature_parallel_tree_learner.cpp:45:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
tests/cpp_tests/test_array_args.cpp:45:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
tests/cpp_tests/test_chunked_array.cpp:252:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
include/LightGBM/utils/array_args.h:115:  Controlled statements inside brackets of while clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/array_args.h:116:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/array_args.h:118:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/array_args.h:119:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/array_args.h:124:  Controlled statements inside brackets of for clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/array_args.h:125:  Controlled statements inside brackets of for clause should be on a separate line  [whitespace/newline] [5]
src/boosting/goss.hpp:33:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/metric/cuda/cuda_binary_metric.cpp:14:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/metric/cuda/cuda_binary_metric.cpp:26:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/treelearner/feature_histogram.cpp:385:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/treelearner/feature_histogram.cpp:564:  Add #include <algorithm> for min  [build/include_what_you_use] [4]
src/treelearner/feature_histogram.cpp:722:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/treelearner/serial_tree_learner.cpp:371:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/serial_tree_learner.cpp:376:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/serial_tree_learner.cpp:248:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/treelearner/serial_tree_learner.cpp:899:  Add #include <string> for string  [build/include_what_you_use] [4]
src/treelearner/serial_tree_learner.cpp:1046:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
tests/cpp_tests/test_arrow.cpp:329:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
tests/cpp_tests/test_serialize.cpp:73:  Add #include <string> for string  [build/include_what_you_use] [4]
include/LightGBM/utils/openmp_wrapper.h:65:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/openmp_wrapper.h:67:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/boosting/sample_strategy.cpp:17:  Add #include <string> for string  [build/include_what_you_use] [4]
src/io/cuda/cuda_metadata.cpp:37:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/file_io.cpp:50:  Add #include <cstdio> for FILE  [build/include_what_you_use] [4]
src/io/file_io.cpp:62:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/io/file_io.cpp:65:  Add #include <string> for string  [build/include_what_you_use] [4]
src/treelearner/cuda/cuda_best_split_finder.cpp:388:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/treelearner/cuda/cuda_data_partition.cpp:359:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
tests/cpp_tests/test_stream.cpp:237:  Add #include <string> for string  [build/include_what_you_use] [4]
tests/cpp_tests/test_stream.cpp:341:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
include/LightGBM/utils/common.h:318:  Controlled statements inside brackets of while clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/common.h:319:  Controlled statements inside brackets of while clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/common.h:320:  Controlled statements inside brackets of while clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/utils/common.h:716:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/application/application.cpp:124:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/application/application.cpp:152:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/application/application.cpp:52:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/application/application.cpp:151:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/application/application.cpp:235:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/cuda/cuda_algorithms.cu:327:  Add #include <algorithm> for min  [build/include_what_you_use] [4]
src/io/dataset_loader.cpp:668:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/dataset_loader.cpp:1171:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/dataset_loader.cpp:1287:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/dataset_loader.cpp:1344:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/dataset_loader.cpp:1417:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/dataset_loader.cpp:36:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/io/dataset_loader.cpp:745:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/io/dataset_loader.cpp:1005:  Add #include <utility> for move  [build/include_what_you_use] [4]
src/io/dataset_loader.cpp:1175:  Add #include <algorithm> for min  [build/include_what_you_use] [4]
src/io/dataset_loader.cpp:1494:  Add #include <unordered_set> for unordered_set<>  [build/include_what_you_use] [4]
src/io/dataset_loader.cpp:1503:  Add #include <string> for string  [build/include_what_you_use] [4]
src/io/dataset_loader.cpp:1543:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
tests/cpp_tests/testutils.cpp:23:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:32:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:37:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:56:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:61:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:91:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:96:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:133:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:135:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:208:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:210:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:275:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:282:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:348:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:351:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:421:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:423:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:437:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
tests/cpp_tests/testutils.cpp:428:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/boosting/gbdt.cpp:213:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/boosting/gbdt.cpp:455:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/boosting/gbdt.cpp:591:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/boosting/gbdt.cpp:599:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/boosting/gbdt.cpp:271:  Add #include <algorithm> for max  [build/include_what_you_use] [4]
src/boosting/gbdt.cpp:437:  Add #include <utility> for move  [build/include_what_you_use] [4]
src/boosting/gbdt.cpp:653:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/boosting/gbdt.cpp:727:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/boosting/gbdt.cpp:796:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/boosting/gbdt.cpp:847:  Add #include <string> for string  [build/include_what_you_use] [4]
src/boosting/rf.hpp:185:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/config.cpp:132:  Add #include <unordered_set> for unordered_set<>  [build/include_what_you_use] [4]
src/io/config.cpp:290:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/io/config.cpp:314:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/io/config.cpp:487:  Add #include <string> for string  [build/include_what_you_use] [4]
src/io/config.cpp:490:  Add #include <algorithm> for sort  [build/include_what_you_use] [4]
src/io/metadata.cpp:59:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/metadata.cpp:404:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/metadata.cpp:458:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/metadata.cpp:514:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/metadata.cpp:800:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/metadata.cpp:806:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/metadata.cpp:813:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/io/metadata.cpp:664:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/main.cpp:29:  Add #include <string> for string  [build/include_what_you_use] [4]
src/metric/map_metric.hpp:89:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/objective/objective_function.cpp:145:  Add #include <string> for string  [build/include_what_you_use] [4]
src/treelearner/voting_parallel_tree_learner.cpp:17:  Do not indent within a namespace.  [whitespace/indent_namespace] [4]
src/treelearner/voting_parallel_tree_learner.cpp:271:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/voting_parallel_tree_learner.cpp:291:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/voting_parallel_tree_learner.cpp:313:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/voting_parallel_tree_learner.cpp:326:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/treelearner/voting_parallel_tree_learner.cpp:174:  Add #include <functional> for greater<>  [build/include_what_you_use] [4]
src/treelearner/voting_parallel_tree_learner.cpp:197:  Add #include <algorithm> for min  [build/include_what_you_use] [4]
include/LightGBM/dataset.h:557:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/dataset.h:559:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/dataset.h:590:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
include/LightGBM/dataset.h:593:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/boosting/boosting.cpp:48:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/boosting/boosting.cpp:56:  Add #include <string> for string  [build/include_what_you_use] [4]
src/boosting/gbdt_prediction.cpp:88:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/c_api.cpp:221:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/c_api.cpp:397:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/c_api.cpp:1606:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/c_api.cpp:1617:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/c_api.cpp:1841:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/c_api.cpp:1878:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/c_api.cpp:1879:  Controlled statements inside brackets of if clause should be on a separate line  [whitespace/newline] [5]
src/c_api.cpp:241:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
src/c_api.cpp:1783:  Add #include <algorithm> for max  [build/include_what_you_use] [4]
src/c_api.cpp:2984:  Add #include <utility> for make_pair  [build/include_what_you_use] [4]
src/metric/metric.cpp:126:  Add #include <string> for string  [build/include_what_you_use] [4]
src/network/network.cpp:19:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/network/network.cpp:51:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/network/network.cpp:164:  Add #include <algorithm> for min  [build/include_what_you_use] [4]
src/treelearner/cuda/cuda_single_gpu_tree_learner.cpp:575:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/treelearner/linear_tree_learner.cpp:81:  Add #include <memory> for unique_ptr<>  [build/include_what_you_use] [4]
src/treelearner/linear_tree_learner.cpp:400:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
src/treelearner/tree_learner.cpp:46:  Add #include <string> for string  [build/include_what_you_use] [4]
tests/cpp_tests/test_single_row.cpp:141:  Add #include <vector> for vector<>  [build/include_what_you_use] [4]
tests/cpp_tests/test_single_row.cpp:151:  Add #include <algorithm> for min  [build/include_what_you_use] [4]

@jameslamb jameslamb changed the title WIP: [ci] [c++] use 'pre-commit' to run 'cpplint', upgrade to 'cpplint' 2.0.2 [ci] [c++] use 'pre-commit' to run 'cpplint', upgrade to 'cpplint' 2.0.2 Aug 21, 2025
@jameslamb jameslamb marked this pull request as ready for review August 21, 2025 04:41
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

Nice changes, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants