# 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-*,

        # Renamed/replaced by cppcoreguidelines-narrowing-conversions. ,
       -bugprone-narrowing-conversions,

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

        # As of 2022-12-19, there are 123 unique warnings. ,
       -bugprone-implicit-widening-of-multiplication-result,

        # As of 2022-12-19, there are 161 unique warnings. ,
       -bugprone-assignment-in-if-condition

    cert-*,

        # 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 2022-12-19,
        # there are 344 warnings. ,
       -cert-err33-c,

        # string-to-number conversion functions that do not verify the
        # validity of the conversion.  As of 2022-12-19, there are 85
        # warnings. ,
       -cert-err34-c,

        # Lots of complaints about constructors of static objects
        # possibly throwing exceptions that cant be caught. As of
        # 2022-12-19, there are 540 warnings. ,
       -cert-err58-cpp,

    clang-analyzer-*,
        # 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,

    # Explicitly list the tests that arent aliases. ,
   -cppcoreguidelines-*,

        # Good. ,
        cppcoreguidelines-init-variables,
        cppcoreguidelines-interfaces-global-init,
        cppcoreguidelines-pro-type-member-init,
        cppcoreguidelines-pro-type-static-cast-downcast,

        # As of 2022-12-19, there are 142 unique warnings. ,
       -cppcoreguidelines-avoid-goto,

        # As of 2022-12-19, there are 1413 unique warnings. ,
       -cppcoreguidelines-avoid-non-const-global-variables,

        # As of 2022-12-19, there are 2503 unique warnings. ,
       -cppcoreguidelines-narrowing-conversions,

        # As of 2022-12-19, there are 213 unique warnings. ,
       -cppcoreguidelines-no-malloc,

        # No gsl. ,
       -cppcoreguidelines-owning-memory,

        # No gsl. Warning on every log message.
        # "do not implicitly decay an array into a pointer; consider
        #  using gsl::array_view or an explicit cast instead" ,
       -cppcoreguidelines-pro-bounds-array-to-pointer-decay,

        # No gsl. Recommends gsl::at be used in 1611 places. ,
       -cppcoreguidelines-pro-bounds-constant-array-index,

        # As of 2022-12-19, there are 4624 unique warnings. ,
       -cppcoreguidelines-pro-bounds-pointer-arithmetic,

        # As of 2022-12-19, there are 17 unique warnings. ,
       -cppcoreguidelines-pro-type-const-cast,

        # As of 2022-12-19, there are 799 unique warnings. ,
       -cppcoreguidelines-pro-type-cstyle-cast,

        # As of 2022-12-19, there are 563 unique warnings. ,
       -cppcoreguidelines-pro-type-reinterpret-cast,

        # Recommends using boost:: to access unions. ,
       -cppcoreguidelines-pro-type-union-access,

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

        # As of 2022-12-19, there are 140 unique warnings. ,
       -cppcoreguidelines-slicing,

        # As of 2022-12-19, there are 1283 unique warnings. ,
       -cppcoreguidelines-special-member-functions,

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

    misc-*,

        # New in clang15. As of 2022-12-19, there are 16055 unique
        # warnings. ,
       -misc-const-correctness

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

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

    modernize-*,

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

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

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

        # New in clang15. As of 2022-12-19, the vast majority of these
        # unique warnings (661 of 700) are from the config.h file. ,
       -modernize-macro-to-enum

    performance-*,

        # The Q_DECLARE_METATYPE macro triggers a warning from this
        # new clang12 checker.  As of 2022-12-19, there vast majority
        # of these (236 of 292) warnings are associated with this
        # macro; the other 56 are in the MythTV code. ,
       -performance-no-int-to-ptr,

    readability-*,

        # Need to decide on an appropriate value. ,
       -readability-function-cognitive-complexity,

        # Not investigated yet. ,
       -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 2022-12-19, there are 16263 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: cppcoreguidelines-pro-type-member-init.IgnoreArrays, value: 1 }
  - { key: cppcoreguidelines-narrowing-conversions.PedanticMode, value: 0 } # test 1 at some point

  - { 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: 3 }
  - { 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' }
