diff --git a/Makefile b/Makefile index 2d33363206..e3fd7d26f3 100644 --- a/Makefile +++ b/Makefile @@ -492,13 +492,25 @@ px4_sitl_default-clang: @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && cmake "$(SRC_DIR)" $(CMAKE_ARGS) -G"$(PX4_CMAKE_GENERATOR)" -DCONFIG=px4_sitl_default -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ @$(PX4_MAKE) -C "$(SRC_DIR)"/build/px4_sitl_default-clang +# Paths to exclude from clang-tidy (auto-generated from .gitmodules + manual additions): +# - All submodules (external code we consume, not edit) +# - Test code (allowed looser style) +# - Example code (educational, not production) +# - Vendored third-party code (e.g., CMSIS_5) +# +# To add manual exclusions, append to CLANG_TIDY_EXCLUDE_EXTRA below. +# Submodules are automatically excluded - no action needed when adding new ones. +CLANG_TIDY_SUBMODULES := $(shell git config --file .gitmodules --get-regexp path | awk '{print $$2}' | tr '\n' '|' | sed 's/|$$//') +CLANG_TIDY_EXCLUDE_EXTRA := src/systemcmds/tests|src/examples|src/modules/gyro_fft/CMSIS_5 +CLANG_TIDY_EXCLUDE := $(CLANG_TIDY_SUBMODULES)|$(CLANG_TIDY_EXCLUDE_EXTRA) + clang-tidy: px4_sitl_default-clang - @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && "$(SRC_DIR)"/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j_clang_tidy) -p . + @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && "$(SRC_DIR)"/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j_clang_tidy) -exclude="$(CLANG_TIDY_EXCLUDE)" -p . # to automatically fix a single check at a time, eg modernize-redundant-void-arg # % run-clang-tidy-4.0.py -fix -j4 -checks=-\*,modernize-redundant-void-arg -p . clang-tidy-fix: px4_sitl_default-clang - @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && "$(SRC_DIR)"/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j_clang_tidy) -fix -p . + @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && "$(SRC_DIR)"/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j_clang_tidy) -exclude="$(CLANG_TIDY_EXCLUDE)" -fix -p . # TODO: Fix cppcheck errors then try --enable=warning,performance,portability,style,unusedFunction or --enable=all cppcheck: px4_sitl_default diff --git a/src/modules/gyro_fft/CMSIS_5/.clang-tidy b/src/modules/gyro_fft/CMSIS_5/.clang-tidy deleted file mode 100644 index 64e1b8f404..0000000000 --- a/src/modules/gyro_fft/CMSIS_5/.clang-tidy +++ /dev/null @@ -1,120 +0,0 @@ ---- -Checks: '*, - -android*, - -bugprone-integer-division, - -cert-dcl50-cpp, - -cert-env33-c, - -cert-err34-c, - -cert-err58-cpp, - -cert-msc30-c, - -cert-msc50-cpp, - -cert-flp30-c, - -clang-analyzer-core.CallAndMessage, - -clang-analyzer-core.NullDereference, - -clang-analyzer-core.UndefinedBinaryOperatorResult, - -clang-analyzer-core.uninitialized.Assign, - -clang-analyzer-core.VLASize, - -clang-analyzer-cplusplus.NewDelete, - -clang-analyzer-cplusplus.NewDeleteLeaks, - -clang-analyzer-deadcode.DeadStores, - -clang-analyzer-optin.cplusplus.VirtualCall, - -clang-analyzer-optin.performance.Padding, - -clang-analyzer-security.FloatLoopCounter, - -clang-analyzer-security.insecureAPI.strcpy, - -clang-analyzer-unix.API, - -clang-analyzer-unix.cstring.BadSizeArg, - -clang-analyzer-unix.Malloc, - -clang-analyzer-unix.MallocSizeof, - -cppcoreguidelines-c-copy-assignment-signature, - -cppcoreguidelines-interfaces-global-init, - -cppcoreguidelines-no-malloc, - -cppcoreguidelines-owning-memory, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-pro-bounds-constant-array-index, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-pro-type-const-cast, - -cppcoreguidelines-pro-type-cstyle-cast, - -cppcoreguidelines-pro-type-member-init, - -cppcoreguidelines-pro-type-reinterpret-cast, - -cppcoreguidelines-pro-type-union-access, - -cppcoreguidelines-pro-type-vararg, - -cppcoreguidelines-special-member-functions, - -fuchsia-default-arguments, - -fuchsia-overloaded-operator, - -google-build-using-namespace, - -google-explicit-constructor, - -google-global-names-in-headers, - -google-readability-braces-around-statements, - -google-readability-casting, - -google-readability-function-size, - -google-readability-namespace-comments, - -google-readability-todo, - -google-runtime-int, - -google-runtime-references, - -hicpp-braces-around-statements, - -hicpp-deprecated-headers, - -hicpp-explicit-conversions, - -hicpp-function-size, - -hicpp-member-init, - -hicpp-no-array-decay, - -hicpp-no-assembler, - -hicpp-no-malloc, - -hicpp-signed-bitwise, - -hicpp-special-member-functions, - -hicpp-use-auto, - -hicpp-use-equals-default, - -hicpp-use-equals-delete, - -hicpp-use-override, - -hicpp-vararg, - -llvm-header-guard, - -llvm-include-order, - -llvm-namespace-comment, - -misc-incorrect-roundings, - -misc-macro-parentheses, - -misc-misplaced-widening-cast, - -misc-redundant-expression, - -misc-unconventional-assign-operator, - -misc-unused-parameters, - -modernize-deprecated-headers, - -modernize-loop-convert, - -modernize-pass-by-value, - -modernize-return-braced-init-list, - -modernize-use-auto, - -modernize-use-bool-literals, - -modernize-use-default-member-init, - -modernize-use-emplace, - -modernize-use-equals-default, - -modernize-use-equals-delete, - -modernize-use-override, - -modernize-use-using, - -performance-inefficient-string-concatenation, - -performance-unnecessary-value-param, - -readability-avoid-const-params-in-decls, - -readability-braces-around-statements, - -readability-container-size-empty, - -readability-delete-null-pointer, - -readability-else-after-return, - -readability-function-size, - -readability-implicit-bool-cast, - -readability-implicit-bool-conversion, - -readability-inconsistent-declaration-parameter-name, - -readability-named-parameter, - -readability-non-const-parameter, - -readability-redundant-control-flow, - -readability-redundant-declaration, - -readability-redundant-member-init, - -readability-simplify-boolean-expr, - -readability-static-accessed-through-instance, - -readability-static-definition-in-anonymous-namespace, - ' -WarningsAsErrors: '*' -CheckOptions: - - key: google-readability-braces-around-statements.ShortStatementLines - value: '1' - - key: google-readability-function-size.BranchThreshold - value: '600' - - key: google-readability-function-size.LineThreshold - value: '4000' - - key: google-readability-function-size.StatementThreshold - value: '4000' -... diff --git a/src/systemcmds/tests/.clang-tidy b/src/systemcmds/tests/.clang-tidy deleted file mode 100644 index 9d2589717a..0000000000 --- a/src/systemcmds/tests/.clang-tidy +++ /dev/null @@ -1,119 +0,0 @@ ---- -Checks: '*, - -android*, - -bugprone-integer-division, - -cert-dcl50-cpp, - -cert-env33-c, - -cert-err34-c, - -cert-err58-cpp, - -cert-msc30-c, - -cert-msc50-cpp, - -cert-flp30-c, - -clang-analyzer-core.CallAndMessage, - -clang-analyzer-core.NullDereference, - -clang-analyzer-core.UndefinedBinaryOperatorResult, - -clang-analyzer-core.uninitialized.Assign, - -clang-analyzer-core.VLASize, - -clang-analyzer-cplusplus.NewDelete, - -clang-analyzer-cplusplus.NewDeleteLeaks, - -clang-analyzer-deadcode.DeadStores, - -clang-analyzer-optin.cplusplus.VirtualCall, - -clang-analyzer-optin.performance.Padding, - -clang-analyzer-security.FloatLoopCounter, - -clang-analyzer-security.insecureAPI.strcpy, - -clang-analyzer-unix.API, - -clang-analyzer-unix.cstring.BadSizeArg, - -clang-analyzer-unix.Malloc, - -clang-analyzer-unix.MallocSizeof, - -cppcoreguidelines-c-copy-assignment-signature, - -cppcoreguidelines-interfaces-global-init, - -cppcoreguidelines-no-malloc, - -cppcoreguidelines-owning-memory, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-pro-bounds-constant-array-index, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-pro-type-const-cast, - -cppcoreguidelines-pro-type-cstyle-cast, - -cppcoreguidelines-pro-type-member-init, - -cppcoreguidelines-pro-type-reinterpret-cast, - -cppcoreguidelines-pro-type-union-access, - -cppcoreguidelines-pro-type-vararg, - -cppcoreguidelines-special-member-functions, - -fuchsia-default-arguments, - -fuchsia-overloaded-operator, - -google-build-using-namespace, - -google-explicit-constructor, - -google-global-names-in-headers, - -google-readability-casting, - -google-readability-function-size, - -google-readability-namespace-comments, - -google-readability-todo, - -google-runtime-int, - -google-runtime-references, - -hicpp-braces-around-statements, - -hicpp-deprecated-headers, - -hicpp-explicit-conversions, - -hicpp-function-size, - -hicpp-member-init, - -hicpp-no-array-decay, - -hicpp-no-assembler, - -hicpp-no-malloc, - -hicpp-signed-bitwise, - -hicpp-special-member-functions, - -hicpp-use-auto, - -hicpp-use-equals-default, - -hicpp-use-equals-delete, - -hicpp-use-override, - -hicpp-vararg, - -llvm-header-guard, - -llvm-include-order, - -llvm-namespace-comment, - -misc-incorrect-roundings, - -misc-macro-parentheses, - -misc-misplaced-widening-cast, - -misc-redundant-expression, - -misc-unconventional-assign-operator, - -misc-unused-parameters, - -modernize-deprecated-headers, - -modernize-loop-convert, - -modernize-pass-by-value, - -modernize-return-braced-init-list, - -modernize-use-auto, - -modernize-use-bool-literals, - -modernize-use-default-member-init, - -modernize-use-emplace, - -modernize-use-equals-default, - -modernize-use-equals-delete, - -modernize-use-override, - -modernize-use-using, - -performance-inefficient-string-concatenation, - -performance-unnecessary-value-param, - -readability-avoid-const-params-in-decls, - -readability-braces-around-statements, - -readability-container-size-empty, - -readability-delete-null-pointer, - -readability-else-after-return, - -readability-function-size, - -readability-implicit-bool-cast, - -readability-implicit-bool-conversion, - -readability-inconsistent-declaration-parameter-name, - -readability-named-parameter, - -readability-non-const-parameter, - -readability-redundant-control-flow, - -readability-redundant-declaration, - -readability-redundant-member-init, - -readability-simplify-boolean-expr, - -readability-static-accessed-through-instance, - -readability-static-definition-in-anonymous-namespace, - ' -WarningsAsErrors: '*' -CheckOptions: - - key: google-readability-braces-around-statements.ShortStatementLines - value: '1' - - key: google-readability-function-size.BranchThreshold - value: '600' - - key: google-readability-function-size.LineThreshold - value: '4000' - - key: google-readability-function-size.StatementThreshold - value: '4000' -...