# Crappy parser.  Only uses a comma to delineate the end of a line, so
# all comments must end with a comma. A single quote inside a comment
# also screws up the parsing.
#
# The goal is to pass all of the following:
#
#     bugprone-*
#     cert-*
#     clang-analyzer-*
#     cppcoreguidelines-*
#     misc-*
#     modernize-*
#     performance-*
#     readability-*
#
# Some specific checks may never be enabled, like
# clang-analyzer-security.insecureAPI.strcpy which requires a missing
# library to fix problems.  Others like modernize-redundant-void-arg
# seem unnecessary.  Some others may never be enabled by default, like
# clang-analyzer-core.CallAndMessage which doesn't understand
# dynamic_cast and gives lots of false positives.
#,

# Skip warnings that are in files in an "external" directory.  Also
# ignore warnings from a file in an "include" directory to ignore
# files that are "installed" from mythtv for mythplugins.  These will
# be caught when processing files in the mythtv directory.
#
# Possible matches in order:
#
# file.h or ./file.h or dir/file.h or ./dir/file.h
# ../dir/file.h
# ../../libmyth<blah>/dir/format.h
#,
#HeaderFilterRegex: '^((\./)?([[:alnum:]]+/)?[[:alnum:]]+\.h|\.\./[[:alnum:]]+/[[:alnum:]]+\.h|\.\./\.\./libmyth[[:alnum:]]+/[[:alnum:]]+\.h|\.\./\.\./external/libmythsoundtouch/[[:alnum:]]+\.h)$'
#,
HeaderFilterRegex: '^((\./)?([[:alnum:]]+/)?[[:alnum:]]+\.h|\.\./[[:alnum:]]+/[[:alnum:]]+\.h|\.\./\.\./libmyth[[:alnum:]]+/[[:alnum:]]+\.h)$'

Checks: '-*,

    bugprone-*,

        # Skip tests that are redirects to other tests. ,
       -bugprone-narrowing-conversions,

        # As of 2022-12-19, there are 1014 unique warnings. ,
       -bugprone-easily-swappable-parameters,

        # As of 2023-09-19, there are 7 unique warnings. 1 is in
        # libmythfreesurround and the others are in libmythmheg. ,
       -bugprone-empty-catch,

        # As of 2023-05-22, there are 97 unique warnings. ,
       -bugprone-implicit-widening-of-multiplication-result,

        # As of 2023-09-19, there are 140 unique warnings. ,
       -bugprone-switch-missing-default-case,

    cert-*,

        # Skip tests that are redirects to other tests. ,
       -cert-con36-c,
       -cert-con54-cpp,
       -cert-ctr56-cpp,
       -cert-dcl03-c,
       -cert-dcl16-c,
       -cert-dcl37-c,
       -cert-dcl51-cpp,
       -cert-dcl54-cpp,
       -cert-dcl59-cpp,
       -cert-err09-cpp,
       -cert-err61-cpp,
       -cert-exp42-c,
       -cert-fio38-c,
       -cert-flp37-c,
       -cert-int09-c,
       -cert-msc24-c,
       -cert-msc30-c
       -cert-msc32-c,
       -cert-msc33-c,
       -cert-msc54-cpp,
       -cert-oop11-cpp,
       -cert-oop54-cpp,
       -cert-pos44-c,
       -cert-pos47-c,
       -cert-sig30-c,
       -cert-str34-c,

        # Dont declare c-style varardic functions. As of 2022-12-19,
        # there are 2 warnings: lirc_client.cpp and vbi.cpp. ,
       -cert-dcl50-cpp,

        # Using function invokes a command interpreter. Should fix.
        # As of 2022-12-19, there are 9 warnings. ,
       -cert-env33-c,

        # Calls to standard library functions where the return value
        # isnt checked. These should all be fixed. As of 2023-05-22,
        # there are 340 warnings. ,
       -cert-err33-c,

        # string-to-number conversion functions that do not verify the
        # validity of the conversion.  As of 2023-05-22, there are 43
        # warnings. ,
       -cert-err34-c,

        # Lots of complaints about constructors of static objects
        # possibly throwing exceptions that cant be caught. As of
        # 2023-05-22, there are 508 warnings. ,
       -cert-err58-cpp,

    clang-analyzer-*,
        # This complains about all instances where an enum is used to
        # define a set of bit flags, and then one or more of those
        # flags are or-ed together. ,
       -clang-analyzer-optin.core.EnumCastOutOfRange,

        # The "safe" versions functions were optional in the standard
        # and were never implemented by GCC or Clang.  There has been
        # a move to have these functions removed from the standard as
        # "the design suffers from far too many problems to
        # correct". There are warnings in 5 or 6 files. ,
       -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
       -clang-analyzer-security.insecureAPI.strcpy,

    cppcoreguidelines-*,

        # Skip tests that are redirects to other tests. ,
       -cppcoreguidelines-avoid-c-arrays,
       -cppcoreguidelines-avoid-magic-numbers,
       -cppcoreguidelines-c-copy-assignment-signature,
       -cppcoreguidelines-explicit-virtual-functions,
       -cppcoreguidelines-macro-to-enum,
       -cppcoreguidelines-noexcept-destructor,
       -cppcoreguidelines-noexcept-move-operations,
       -cppcoreguidelines-noexcept-swap,
       -cppcoreguidelines-non-private-member-variables-in-classes,
       -cppcoreguidelines-use-default-member-init,

        # Skip tests that recommend usage of the Microsoft Guidelines
        # Support Library.  https://github.com/microsoft/GSL ,
       -cppcoreguidelines-owning-memory,
       -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
       -cppcoreguidelines-pro-bounds-constant-array-index,

        # Skip tests that recommend usage of the boost:: framework to
        # access unions. https://www.boost.org/ ,
       -cppcoreguidelines-pro-type-union-access,

        # As of 2024-08-01, there are 110 unique warnings. ,
       -cppcoreguidelines-avoid-const-or-ref-data-members,

        # As of 2024-08-01, there are 12256 unique warnings. ,
       -cppcoreguidelines-avoid-do-while,

        # As of 2024-08-03, there are 135 unique warnings. ,
       -cppcoreguidelines-avoid-goto,

        # As of 2023-05-22, there are 1257 unique warnings. ,
       -cppcoreguidelines-avoid-non-const-global-variables,

        # As of 2024-08-01, there are 2 warnings. ,
       -cppcoreguidelines-macro-usage,

        # As of 2023-05-22, there are 374 unique warnings. ,
       -cppcoreguidelines-narrowing-conversions,

        # As of 2024-08-02, there are 210 unique warnings. ,
       -cppcoreguidelines-no-malloc,

        # As of 2024-08-02, there are 4624 unique warnings. ,
       -cppcoreguidelines-pro-bounds-pointer-arithmetic,

        # As of 2024-08-02, there are 22 unique warnings. ,
       -cppcoreguidelines-pro-type-const-cast,

        # As of 2023-05-22, there are 744 unique warnings. ,
       -cppcoreguidelines-pro-type-cstyle-cast,

        # As of 2024-08-02, there are 498 unique warnings. ,
       -cppcoreguidelines-pro-type-reinterpret-cast,

        # Warns on every (*)printf, sscanf,open, ioctl, etc. ,
       -cppcoreguidelines-pro-type-vararg,

        # As of 2024-08-02, there are 140 unique warnings. ,
       -cppcoreguidelines-slicing,

        # As of 2024-08-02, there are 1547 unique warnings. ,
       -cppcoreguidelines-special-member-functions,

        # As of 2024-08-01, there are 207 unique warnings. ,
       -cppcoreguidelines-virtual-class-destructor,

   -google-explicit-constructor,
   -google-runtime-int,

    misc-*,

        # As of 2024-08-02, there are 15970 unique warnings. ,
       -misc-const-correctness,

        # As of 2023-09-19, there are 115517 unique warnings. ,
       -misc-include-cleaner,

        # Complains about every public or protected variable in a class. ,
       -misc-non-private-member-variables-in-classes,

        # As of 2028-08-02, there are 420 unique warnings. 195 are
        # related to the Q_DECLARE_METATYPE macro and the other 225
        # are in MythTV. ,
       -misc-no-recursion,

        # New in clang16. As of 2023-05-03, there are 1445 unique
        # warnings. ,
       -misc-use-anonymous-namespace,

        # Temporarily disable this. ,
       -misc-use-internal-linkage,

    modernize-*,

        # Noisy!!!  foo(void) => foo()  ,
       -modernize-redundant-void-arg,

        # As of 2024-08-08, all remaining warnings remaining come from
        # calls to QFETCH Q_GLOBAL_STATIC_WITH_ARGS and cant be fixed
        # by us. ,
       -modernize-type-traits,

        # Why would anyone want this? ,
       -modernize-use-trailing-return-type,

        # Disable newer C++14/17 tests for now. ,
       -modernize-use-nodiscard,

        # Renamed from cppcoreguidelines-macro-to-enum in clang15. As
        # of 2023-05-22, there are 41 unique warnings. ,
       -modernize-macro-to-enum,

    performance-*,

        # As of 2023-09-19, there are 443 unique warnings. ,
       -performance-avoid-endl,

        # As of 2024-08-01, new filtering reduces this count to 14
        # unique warnings. ,
       -performance-enum-size,

        # As of 2024-08-01, new filtering reduces this count to 35
        # unique warnings. ,
       -performance-no-int-to-ptr,

    readability-*,

        # As of 2023-09-19, there are 315 unique warnings. ,
       -readability-avoid-unconditional-preprocessor-if,

        # Need to decide on an appropriate value.  As of 2024-08-02
        # there are 1753 unique warnings at the default complexity
        # value. ,
       -readability-function-cognitive-complexity,

        # Need to decide on an appropriate value.  As of 2024-08-02
        # there are only 2 unique warnings at the default size limit
        # of 800 statements. ,
       -readability-function-size,

        # Whats wrong with single character variable names? As of
        # 2022-12-19, there are 9889 unique warnings. ,
       -readability-identifier-length,

        # Wants to rewrite lots of implicit nullptr tests. As of
        # 2022-12-19, there are 426 unique warnings. ,
       -readability-implicit-bool-conversion,

        # As of 2023-05-22, there are 14798 unique warnings. ,
       -readability-magic-numbers,

        # Doesn''t understand Qt signals/slots. ,
       -readability-redundant-access-specifiers,

'

CheckOptions:
  - { key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1 }
  - { key: bugprone-pointer-arithmetic-on-polymorphic-object.IgnoreInheritedVirtualFunctions, value: 1 }

  - { key: cppcoreguidelines-pro-type-member-init.IgnoreArrays, value: 1 }
  - { key: cppcoreguidelines-narrowing-conversions.PedanticMode, value: 0 } # test 1 at some point

  - { key: misc-header-include-cycle.IgnoredFilesList, value: 'qglobal.h;mem.h;common.h' }

  - { key: modernize-make-shared.IgnoreMacros,             value: 0 }
  - { key: modernize-make-unique.IgnoreMacros,             value: 0 }
  - { key: modernize-use-bool-literals.IgnoreMacros,       value: 1 }
  - { key: modernize-use-default-member-init.IgnoreMacros, value: 1 }
  - { key: modernize-use-equals-default.IgnoreMacros,      value: 0 }
  - { key: modernize-use-nullptr.NullMacros,               value: 'Z_NULL' }
  - { key: modernize-use-using.IgnoreMacros,               value: 1 }

  - { key: performance-inefficient-vector-operation.VectorLikeClasses,
    value: '::std::vector,QList,QByteArrayList,QItemSelection,QQueue,QStringList' }

  - { key: readability-braces-around-statements.ShortStatementLines,       value: 4 }
  - { key: readability-implicit-bool-conversion.AllowPointerConditions,    value: 1 }
  - { key: readability-implicit-bool-conversion.AllowIntegerConditions,    value: 1 }
  - { key: readability-inconsistent-declaration-parameter-name.strict,     value: 1 }
  - { key: readability-redundant-member-init.IgnoreBaseInCopyConstructors, value: 1 }
  - { key: readability-redundant-declaration.IgnoreMacros,                 value: 0 }
  - { key: readability-simplify-boolean-expr.chainedconditionalreturn,     value: 1 }
  - { key: readability-simplify-boolean-expr.chainedconditionalassignment, value: 1 }
  - { key: readability-uppercase-literal-suffix.IgnoreMacros,              value: 0 }
  - { key: readability-simplify-subscript-expr.Types,
    value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array;QByteArray;QString' }

  - { key: readability-identifier-naming.PrivateMethodCase,     value: 'aNy_CasE' }
  - { key: readability-identifier-naming.PrivateMemberCase,     value: 'camelBack' }
  - { key: readability-identifier-naming.PrivateMemberPrefix,   value: 'm_'}
  - { key: readability-identifier-naming.ProtectedMethodCase,   value: 'aNy_CasE' }
  - { key: readability-identifier-naming.ProtectedMemberCase,   value: 'camelBack' }
  - { key: readability-identifier-naming.ProtectedMemberPrefix, value: 'm_'}
  - { key: readability-identifier-naming.PuplicMethodCase,      value: 'aNy_CasE' }
  - { key: readability-identifier-naming.PuplicMemberCase,      value: 'camelBack' }
  - { key: readability-identifier-naming.PuplicMemberPrefix,    value: 'm_'}
  - { key: readability-identifier-naming.ClassConstantCase,     value: 'aNy_CasE' }
  - { key: readability-identifier-naming.ClassConstantPrefix,   value: 'k' }

  - { key: google-runtime-int.TypeSuffix,   value: '_t' }
