added clang-tidy to CI (#3218)
This commit is contained in:
parent
563c9dd9cc
commit
5de58c4ddd
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
Checks: '*,-abseil-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-use-override,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-misc-unused-using-decls,-modernize-use-emplace,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-performance-for-range-copy,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-readability-misleading-indentation,-misc-unused-parameters-,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle'
|
||||
Checks: '*,-abseil-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-use-override,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-misc-unused-using-decls,-modernize-use-emplace,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-performance-for-range-copy,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-readability-misleading-indentation,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle'
|
||||
WarningsAsErrors: '*'
|
||||
CheckOptions:
|
||||
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
||||
value: '1'
|
|
@ -0,0 +1,44 @@
|
|||
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
|
||||
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
|
||||
name: clang-tidy
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
fail-fast: false # Prefer quick result
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install missing software
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install z3 libz3-dev
|
||||
sudo apt-get install clang-tidy
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v2
|
||||
with:
|
||||
modules: 'qtcharts'
|
||||
|
||||
- name: Prepare CMake
|
||||
run: |
|
||||
mkdir cmake.output
|
||||
cd cmake.output
|
||||
# cannot include GUI since we need to generate the ui_*.h files first
|
||||
cmake -G "Unix Makefiles" -DUSE_Z3=On -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off ..
|
||||
cd ..
|
||||
|
||||
- name: Clang-Tidy
|
||||
run: |
|
||||
# make sure the precompiled headers exist
|
||||
make -C cmake.output lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
|
||||
make -C cmake.output test/CMakeFiles/testrunner.dir/cmake_pch.hxx.cxx
|
||||
cmake --build cmake.output --target run-clang-tidy 2> /dev/null
|
|
@ -1,13 +1,15 @@
|
|||
find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-11 clang-tidy-10 clang-tidy-9 clang-tidy-8)
|
||||
message(STATUS "CLANG_TIDY=${CLANG_TIDY}")
|
||||
if (CLANG_TIDY)
|
||||
set(CLANG_TIDY_SRCS ${CMAKE_SOURCE_DIR}/cli/*.cpp ${CMAKE_SOURCE_DIR}/lib/*.cpp)
|
||||
if (BUILD_GUI)
|
||||
list(APPEND CLANG_TIDY_SRCS ${CMAKE_SOURCE_DIR}/gui/*.cpp)
|
||||
endif()
|
||||
if (BUILD_TESTS)
|
||||
list(APPEND CLANG_TIDY_SRCS ${CMAKE_SOURCE_DIR}/test/*.cpp)
|
||||
if (NOT NPROC)
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(NPROC)
|
||||
if(NPROC EQUAL 0)
|
||||
message(FATAL_ERROR "could not get processor count")
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "NPROC=${NPROC}")
|
||||
|
||||
add_custom_target(run-clang-tidy ${CLANG_TIDY} -p=${CMAKE_BINARY_DIR} ${CLANG_TIDY_SRCS})
|
||||
find_program(RUN_CLANG_TIDY NAMES run-clang-tidy run-clang-tidy-11 run-clang-tidy-10 run-clang-tidy-9 run-clang-tidy-8)
|
||||
message(STATUS "RUN_CLANG_TIDY=${RUN_CLANG_TIDY}")
|
||||
if (RUN_CLANG_TIDY)
|
||||
# disable all compiler warnings since we are just interested in the tidy ones
|
||||
add_custom_target(run-clang-tidy ${RUN_CLANG_TIDY} -p=${CMAKE_BINARY_DIR} -j ${NPROC} -extra-arg=-w -quiet)
|
||||
endif()
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
Checks: '-*,misc-definitions-in-headers'
|
||||
CheckOptions:
|
||||
- { key: HeaderFileExtensions, value: "x" }
|
|
@ -1169,7 +1169,7 @@ static bool isForLoopCondition(const Token * const tok)
|
|||
|
||||
/**
|
||||
* Is token used a boolean (cast to a bool, or used as a condition somewhere)
|
||||
* @param tok
|
||||
* @param tok the token to check
|
||||
* @param checkingParent true if we are checking a parent. This is used to know
|
||||
* what we are checking. For instance in `if (i == 2)`, isUsedAsBool("==") is
|
||||
* true whereas isUsedAsBool("i") is false, but it might call
|
||||
|
|
|
@ -562,6 +562,7 @@ std::vector<CheckClass::Usage> CheckClass::createUsageList(const Scope *scope)
|
|||
std::vector<Usage> ret;
|
||||
std::vector<const Variable *> varlist;
|
||||
getAllVariableMembers(scope, varlist);
|
||||
ret.reserve(varlist.size());
|
||||
for (const Variable *var: varlist)
|
||||
ret.emplace_back(var);
|
||||
return ret;
|
||||
|
|
|
@ -424,8 +424,8 @@ void execute(const Token *expr,
|
|||
|
||||
else if (expr->isComparisonOp()) {
|
||||
MathLib::bigint result1(0), result2(0);
|
||||
bool error1 = 0;
|
||||
bool error2 = 0;
|
||||
bool error1 = false;
|
||||
bool error2 = false;
|
||||
execute(expr->astOperand1(), programMemory, &result1, &error1);
|
||||
execute(expr->astOperand2(), programMemory, &result2, &error2);
|
||||
if (error1 && error2) {
|
||||
|
|
|
@ -1815,7 +1815,7 @@ namespace {
|
|||
const ScopeInfo3 * findScopeRecursive(const std::string & scope) const {
|
||||
if (fullName.size() < scope.size() &&
|
||||
fullName == scope.substr(0, fullName.size())) {
|
||||
for (auto & child : children) {
|
||||
for (const auto & child : children) {
|
||||
if (child.fullName == scope && &child != this)
|
||||
return &child;
|
||||
else {
|
||||
|
|
|
@ -14,7 +14,7 @@ add_executable(dmake EXCLUDE_FROM_ALL
|
|||
${CMAKE_SOURCE_DIR}/cli/filelister.cpp
|
||||
${srcs_tools}
|
||||
${CMAKE_SOURCE_DIR}/lib/utils.cpp
|
||||
${CMAKE_SOURCE_DIR}/externals/simplecpp/simplecpp
|
||||
${CMAKE_SOURCE_DIR}/externals/simplecpp/simplecpp.cpp
|
||||
)
|
||||
target_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/cli ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp)
|
||||
if (WIN32 AND NOT BORLAND)
|
||||
|
|
Loading…
Reference in New Issue