Fix CPP lint. (#8807)

This commit is contained in:
Jiaming Yuan 2023-02-15 20:16:35 +08:00 committed by GitHub
parent e62167937b
commit 594371e35b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 35 additions and 16 deletions

View File

@ -144,7 +144,18 @@ jobs:
python -m pip install wheel setuptools cpplint pylint python -m pip install wheel setuptools cpplint pylint
- name: Run lint - name: Run lint
run: | run: |
python dmlc-core/scripts/lint.py xgboost cpp R-package/src python3 dmlc-core/scripts/lint.py xgboost cpp R-package/src
python3 dmlc-core/scripts/lint.py --exclude_path \
python-package/xgboost/dmlc-core \
python-package/xgboost/include \
python-package/xgboost/lib \
python-package/xgboost/rabit \
python-package/xgboost/src \
--pylint-rc python-package/.pylintrc \
xgboost \
cpp \
include src python-package
sphinx: sphinx:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -8,15 +8,16 @@
#define XGBOOST_METRIC_H_ #define XGBOOST_METRIC_H_
#include <dmlc/registry.h> #include <dmlc/registry.h>
#include <xgboost/model.h>
#include <xgboost/data.h>
#include <xgboost/base.h> #include <xgboost/base.h>
#include <xgboost/data.h>
#include <xgboost/host_device_vector.h> #include <xgboost/host_device_vector.h>
#include <xgboost/model.h>
#include <vector>
#include <string>
#include <functional> #include <functional>
#include <memory> // shared_ptr
#include <string>
#include <utility> #include <utility>
#include <vector>
namespace xgboost { namespace xgboost {
struct Context; struct Context;

View File

@ -19,7 +19,7 @@ const MetaInfo &SparsePageDMatrix::Info() const { return info_; }
namespace detail { namespace detail {
// Use device dispatch // Use device dispatch
std::size_t NSamplesDevice(DMatrixProxy *) std::size_t NSamplesDevice(DMatrixProxy *) // NOLINT
#if defined(XGBOOST_USE_CUDA) #if defined(XGBOOST_USE_CUDA)
; // NOLINT ; // NOLINT
#else #else
@ -28,7 +28,7 @@ std::size_t NSamplesDevice(DMatrixProxy *)
return 0; return 0;
} }
#endif #endif
std::size_t NFeaturesDevice(DMatrixProxy *) std::size_t NFeaturesDevice(DMatrixProxy *) // NOLINT
#if defined(XGBOOST_USE_CUDA) #if defined(XGBOOST_USE_CUDA)
; // NOLINT ; // NOLINT
#else #else

View File

@ -5,7 +5,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cub/cub.cuh> #include <cub/cub.cuh> // NOLINT
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <tuple> #include <tuple>

View File

@ -6,6 +6,7 @@
#define XGBOOST_METRIC_METRIC_COMMON_H_ #define XGBOOST_METRIC_METRIC_COMMON_H_
#include <limits> #include <limits>
#include <memory> // shared_ptr
#include <string> #include <string>
#include "../common/common.h" #include "../common/common.h"

View File

@ -4,7 +4,7 @@
#include <thrust/sort.h> #include <thrust/sort.h>
#include <cstdint> // std::int32_t #include <cstdint> // std::int32_t
#include <cub/cub.cuh> #include <cub/cub.cuh> // NOLINT
#include "../common/cuda_context.cuh" // CUDAContext #include "../common/cuda_context.cuh" // CUDAContext
#include "../common/device_helpers.cuh" #include "../common/device_helpers.cuh"

View File

@ -3,6 +3,7 @@
*/ */
#include "cpu_treeshap.h" #include "cpu_treeshap.h"
#include <algorithm> // copy
#include <cinttypes> // std::uint32_t #include <cinttypes> // std::uint32_t
#include "predict_fn.h" // GetNextNode #include "predict_fn.h" // GetNextNode

View File

@ -1,6 +1,10 @@
#ifndef XGBOOST_PREDICTOR_CPU_TREESHAP_H_
#define XGBOOST_PREDICTOR_CPU_TREESHAP_H_
/** /**
* Copyright by XGBoost Contributors 2017-2022 * Copyright by XGBoost Contributors 2017-2022
*/ */
#include <vector> // vector
#include "xgboost/tree_model.h" // RegTree #include "xgboost/tree_model.h" // RegTree
namespace xgboost { namespace xgboost {
@ -15,3 +19,4 @@ void CalculateContributions(RegTree const &tree, const RegTree::FVec &feat,
std::vector<float> *mean_values, bst_float *out_contribs, int condition, std::vector<float> *mean_values, bst_float *out_contribs, int condition,
unsigned condition_feature); unsigned condition_feature);
} // namespace xgboost } // namespace xgboost
#endif // XGBOOST_PREDICTOR_CPU_TREESHAP_H_