Commit 18b1f2b5 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'p/clang-tidy-fixes' into 'master'

Fix some warnings reported by clang-tidy

See merge request allpix-squared/allpix-squared!651
parents e2d21e85 0c76c81b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4,9 +4,9 @@ Checks : '-*,
          performance-*,
          google-*,-google-readability-todo,-google-build-using-namespace,-google-readability-namespace-comments,-google-runtime-references,-google-runtime-int,
          readability-*,-readability-named-parameter,-readability-inconsistent-declaration-parameter-name,-readability-avoid-const-params-in-decls,-readability-simplify-boolean-expr,-readability-redundant-declaration,-readability-else-after-return,-readability-magic-numbers,-readability-isolate-declaration,-readability-uppercase-literal-suffix,-readability-const-return-type,-readability-convert-member-functions-to-static,-readability-function-cognitive-complexity,
          llvm-*,-llvm-include-order,-llvm-header-guard,-llvm-namespace-comment,-llvm-qualified-auto,
          llvm-*,-llvm-include-order,-llvm-header-guard,-llvm-namespace-comment,-llvm-qualified-auto,-llvm-else-after-return,
          modernize-*,-modernize-raw-string-literal,-modernize-use-nodiscard,-modernize-use-trailing-return-type,-modernize-avoid-bind,
          cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-owning-memory,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-macro-usage,-cppcoreguidelines-non-private-member-variables-in-classes,
          cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-owning-memory,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-macro-usage,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-avoid-non-const-global-variables,
          cert-*,-cert-err58-cpp,-cert-err34-c,-cert-msc51-cpp,-cert-msc32-c,-cert-dcl16-c,-cert-oop54-cpp,
          misc-*,-misc-noexcept-move-constructor,-misc-non-private-member-variables-in-classes,
          clang-analyzer-*,-clang-analyzer-alpha*,-clang-analyzer-core*,-clang-analyzer-cplusplus*,-clang-analyzer-optin*'
+0 −10
Original line number Diff line number Diff line
@@ -322,16 +322,6 @@ MACRO(ALLPIX_MODULE_REQUIRE_GEANT4_INTERFACE name)
    TARGET_LINK_LIBRARIES(${name} ${ALLPIX_GEANT4_INTERFACE})
ENDMACRO()

# Macro to set up Eigen3:: targets
MACRO(ALLPIX_SETUP_EIGEN_TARGETS)

    IF(NOT TARGET Eigen3::Eigen)
        ADD_LIBRARY(Eigen3::Eigen INTERFACE IMPORTED GLOBAL)
        SET_TARGET_PROPERTIES(Eigen3::Eigen PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${EIGEN3_INCLUDE_DIR})
    ENDIF()

ENDMACRO()

# Macro to set up ROOT:: targets so that we can use the same code for root 6.8 and for root 6.10 and beyond
# Inpsired by CMake build system of DD4Hep
MACRO(ALLPIX_SETUP_ROOT_TARGETS)
+8 −6
Original line number Diff line number Diff line
@@ -115,13 +115,15 @@ IF(CLANG_TIDY AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

        ADD_CUSTOM_TARGET(
            lint
            COMMAND ${RUN_CLANG_TIDY} -fix -format -header-filter=${CMAKE_SOURCE_DIR} -j${NPROC}
            COMMAND ${RUN_CLANG_TIDY} -clang-tidy-binary=${CLANG_TIDY} -fix -format -header-filter=${CMAKE_SOURCE_DIR}
                    -j${NPROC}
            COMMENT "Auto fixing problems in all source files")

        ADD_CUSTOM_TARGET(
            check-lint
            COMMAND
                ${RUN_CLANG_TIDY} -header-filter=${CMAKE_SOURCE_DIR} -j${NPROC} | tee ${CMAKE_BINARY_DIR}/check_lint_file.txt
                ${RUN_CLANG_TIDY} -clang-tidy-binary=${CLANG_TIDY} -header-filter=${CMAKE_SOURCE_DIR} -j${NPROC} | tee
                ${CMAKE_BINARY_DIR}/check_lint_file.txt
                # WARNING: fix to stop with error if there are problems
            COMMAND ! grep -c ": error: " ${CMAKE_BINARY_DIR}/check_lint_file.txt > /dev/null
            COMMENT "Checking for problems in source files")
@@ -143,16 +145,16 @@ IF(CLANG_TIDY AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

        ADD_CUSTOM_TARGET(
            lint-diff
            COMMAND git diff --unified=0 origin/${TARGET_BRANCH}... | ${CLANG_TIDY_DIFF} -path=${CMAKE_BINARY_DIR} -p1 -fix
                    -j${NPROC}
            COMMAND git diff --unified=0 origin/${TARGET_BRANCH}... | ${CLANG_TIDY_DIFF} -clang-tidy-binary=${CLANG_TIDY}
                    -path=${CMAKE_BINARY_DIR} -p1 -fix -j${NPROC}
            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
            COMMENT "Auto fixing problems in differing source files")

        ADD_CUSTOM_TARGET(
            check-lint-diff
            COMMAND
                git diff --unified=0 origin/${TARGET_BRANCH}... | ${CLANG_TIDY_DIFF} -path=${CMAKE_BINARY_DIR} -p1 -j${NPROC}
                | tee ${CMAKE_BINARY_DIR}/check_lint_file.txt
                git diff --unified=0 origin/${TARGET_BRANCH}... | ${CLANG_TIDY_DIFF} -clang-tidy-binary=${CLANG_TIDY}
                -path=${CMAKE_BINARY_DIR} -p1 -j${NPROC} | tee ${CMAKE_BINARY_DIR}/check_lint_file.txt
                # WARNING: fix to stop with error if there are problems
            COMMAND ! grep -c ": error: " ${CMAKE_BINARY_DIR}/check_lint_file.txt > /dev/null
            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+1 −1
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ std::vector<std::string> Configuration::getUnusedKeys() const {
 * String is recursively parsed for all pair of [ and ] brackets. All parts between single or double quotation marks are
 * skipped.
 */
std::unique_ptr<Configuration::parse_node> Configuration::parse_value(std::string str, int depth) {
std::unique_ptr<Configuration::parse_node> Configuration::parse_value(std::string str, int depth) { // NOLINT

    auto node = std::make_unique<parse_node>();
    str = allpix::trim(str);
+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ std::set<Pixel::Index> RadialStripDetectorModel::getNeighbors(const Pixel::Index
        for(int j = static_cast<int>(-distance); j <= static_cast<int>(distance); j++) {
            // Add to final neighbors if strip is within the pixel matrix
            if(isWithinMatrix(row_seed_x + j, row_seed_y)) {
                neighbors.push_back({row_seed_x + j, row_seed_y});
                neighbors.emplace_back(row_seed_x + j, row_seed_y);
            }
        }
    }
Loading