mirror of
https://github.com/nlohmann/json.git
synced 2026-10-27 16:28:57 +00:00
* Document clang-tidy exclusions and drop unneeded ones Re-enable every excluded check in a run of clang-tidy 22 over all tests and remove the seven that never fire (cert-err58-cpp, clang-analyzer-webkit.NoUncountedMemberChecker, cppcoreguidelines-virtual-class-destructor, google-readability-function-size, hicpp-function-size, hicpp-no-assembler, readability-function-size). Document the reason for every remaining exclusion at the top of the file. Exclude in advance the checks that only exist in clang-tidy 23 and are noise here (bugprone-signed-bitwise, *-explicit-constructor, readability-trailing-comma, modernize-use-string-view), plus modernize-use-integer-sign-comparison, which needs C++20 std::cmp_less and flags deliberate casts. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix clang-tidy findings in documentation examples and replace redundant aliases Apply clang-tidy fixes to the documentation examples: - performance-avoid-endl: std::endl -> '\n' - readability-qualified-auto: auto -> auto* / const auto* - performance-for-range-copy: copy -> const reference - google-readability-casting: C-style cast -> static_cast Replace redundant aliases (readability-redundant-qualified-alias) such as "using json = nlohmann::json;" with "using nlohmann::json;" in the documentation, README, examples, tests, and benchmarks. Aliases at class scope and aliases of other types (with_base_class_t etc.) are kept. No changes to the library or its public API. All changed examples were compiled and run; their output matches the stored .output files (except max_size and meta, which depend on the platform and compiler). Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Format doc examples with the pinned astyle Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
115 lines
5.8 KiB
YAML
115 lines
5.8 KiB
YAML
# Style or vendor rule sets that do not fit a header-only library:
|
|
# altera-*, fuchsia-*, llvmlibc-*, android-cloexec-fopen, boost-use-ranges, llvm-header-guard,
|
|
# llvm-include-order, llvm-prefer-static-over-anonymous-namespace, llvm-use-ranges,
|
|
# misc-use-anonymous-namespace, google-runtime-float, google-runtime-int, hicpp-signed-bitwise,
|
|
# bugprone-signed-bitwise, hicpp-explicit-conversions, google-explicit-constructor,
|
|
# cppcoreguidelines-explicit-constructor, misc-explicit-constructor (implicit conversions are the
|
|
# API), readability-trailing-comma,
|
|
# hicpp-avoid-goto / cppcoreguidelines-avoid-goto, hicpp-no-array-decay,
|
|
# hicpp-uppercase-literal-suffix, readability-uppercase-literal-suffix, modernize-use-trailing-return-type.
|
|
# Constructs the library needs on purpose (the library supports C++11 and legacy compilers):
|
|
# cppcoreguidelines-macro-usage, cppcoreguidelines-avoid-do-while (macros),
|
|
# cppcoreguidelines-pro-bounds-*, cppcoreguidelines-pro-type-reinterpret-cast,
|
|
# cppcoreguidelines-pro-type-union-access (parsers, serializers, basic_json's value union),
|
|
# cppcoreguidelines-avoid-const-or-ref-data-members, cppcoreguidelines-rvalue-reference-param-not-moved,
|
|
# cppcoreguidelines-avoid-non-const-global-variables, misc-non-private-member-variables-in-classes,
|
|
# misc-no-recursion (value walks are recursive, bounded by detail::recursion_depth_limit()),
|
|
# modernize-type-traits, modernize-use-constraints, modernize-use-ranges, modernize-use-std-numbers,
|
|
# modernize-use-designated-initializers, modernize-use-nodiscard, modernize-concat-nested-namespaces,
|
|
# readability-redundant-typename, readability-redundant-parentheses,
|
|
# readability-redundant-access-specifiers, readability-simplify-boolean-expr,
|
|
# readability-use-concise-preprocessor-directives, modernize-use-string-view,
|
|
# modernize-use-integer-sign-comparison (needs std::cmp_less; the flagged
|
|
# static_cast<std::size_t>(end - pos) < n comparisons are deliberate)
|
|
# (all need a newer standard or compiler than C++11, or would change macro-generated or
|
|
# deliberately explicit code).
|
|
# Too noisy to be useful (numeric parsing/formatting code, doctest, tests):
|
|
# bugprone-easily-swappable-parameters, cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers,
|
|
# readability-identifier-length, readability-function-cognitive-complexity, performance-enum-size,
|
|
# concurrency-mt-unsafe, misc-confusable-identifiers, misc-include-cleaner (run on its own for
|
|
# the consumer headers in cmake/ci.cmake).
|
|
# portability-avoid-pragma-once: kept disabled on purpose. #pragma once is accepted
|
|
# by every supported compiler, and tools/amalgamate/amalgamate.py strips it from
|
|
# single_include, so there is nothing left to fix here.
|
|
|
|
Checks: '*,
|
|
|
|
-altera-id-dependent-backward-branch,
|
|
-altera-struct-pack-align,
|
|
-altera-unroll-loops,
|
|
-android-cloexec-fopen,
|
|
-boost-use-ranges,
|
|
-bugprone-easily-swappable-parameters,
|
|
-bugprone-signed-bitwise,
|
|
-concurrency-mt-unsafe,
|
|
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
|
-cppcoreguidelines-avoid-do-while,
|
|
-cppcoreguidelines-avoid-goto,
|
|
-cppcoreguidelines-avoid-magic-numbers,
|
|
-cppcoreguidelines-avoid-non-const-global-variables,
|
|
-cppcoreguidelines-explicit-constructor,
|
|
-cppcoreguidelines-macro-usage,
|
|
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
|
|
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
|
-cppcoreguidelines-pro-bounds-constant-array-index,
|
|
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
|
-cppcoreguidelines-pro-type-reinterpret-cast,
|
|
-cppcoreguidelines-pro-type-union-access,
|
|
-cppcoreguidelines-rvalue-reference-param-not-moved,
|
|
-fuchsia-default-arguments-calls,
|
|
-fuchsia-default-arguments-declarations,
|
|
-fuchsia-overloaded-operator,
|
|
-google-explicit-constructor,
|
|
-google-runtime-float,
|
|
-google-runtime-int,
|
|
-hicpp-avoid-goto,
|
|
-hicpp-explicit-conversions,
|
|
-hicpp-no-array-decay,
|
|
-hicpp-signed-bitwise,
|
|
-hicpp-uppercase-literal-suffix,
|
|
-llvm-header-guard,
|
|
-llvm-include-order,
|
|
-llvm-prefer-static-over-anonymous-namespace,
|
|
-llvm-use-ranges,
|
|
-llvmlibc-*,
|
|
-misc-use-anonymous-namespace,
|
|
-misc-confusable-identifiers,
|
|
-misc-explicit-constructor,
|
|
-misc-include-cleaner,
|
|
-misc-no-recursion,
|
|
-misc-non-private-member-variables-in-classes,
|
|
-modernize-concat-nested-namespaces,
|
|
-modernize-type-traits,
|
|
-modernize-use-constraints,
|
|
-modernize-use-designated-initializers,
|
|
-modernize-use-integer-sign-comparison,
|
|
-modernize-use-nodiscard,
|
|
-modernize-use-ranges,
|
|
-modernize-use-string-view,
|
|
-modernize-use-std-numbers,
|
|
-modernize-use-trailing-return-type,
|
|
-performance-enum-size,
|
|
-portability-avoid-pragma-once,
|
|
-readability-function-cognitive-complexity,
|
|
-readability-identifier-length,
|
|
-readability-magic-numbers,
|
|
-readability-redundant-access-specifiers,
|
|
-readability-redundant-parentheses,
|
|
-readability-redundant-typename,
|
|
-readability-simplify-boolean-expr,
|
|
-readability-trailing-comma,
|
|
-readability-uppercase-literal-suffix,
|
|
-readability-use-concise-preprocessor-directives'
|
|
|
|
CheckOptions:
|
|
- key: hicpp-special-member-functions.AllowSoleDefaultDtor
|
|
value: 1
|
|
# clang-tidy 22.1 extended this check to classes and enums; the test files
|
|
# define many such helper types at namespace scope, which is harmless
|
|
- key: misc-use-internal-linkage.AnalyzeTypes
|
|
value: false
|
|
|
|
WarningsAsErrors: '*'
|
|
|
|
HeaderFilterRegex: '.*hpp$'
|