diff --git a/.clang-tidy b/.clang-tidy index 665bb05778fe8..e2eabbe2ee611 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,30 +1,60 @@ --- -# turn off readability-braces-around-statements to allow single line statement like 'if (x == y) doSomething();' -Checks: '-*,cppcoreguidelines-*,google-*,readability-*,modernize-*,-readability-braces-around-statements,-google-runtime-references,-cppcoreguidelines-pro-type-reinterpret-cast' -WarningsAsErrors: '' + +# NOTE: +# The check is a multiline string here. Comment must not be moved into the string. +# Be sure to keep the disabled rules alphabetically sorted. +# +# Checks that are turned off: +# +# -cppcoreguidelines-macro-usage: There are a lot of false-positives like Function-like macro 'Foo' used; consider a 'constexpr' template function +# -cppcoreguidelines-pro-type-reinterpret-cast: Originally turned off. +# -google-readability-todo: Not enforced. +# -google-runtime-references: https://github.com/microsoft/onnxruntime/blob/main/docs/Coding_Conventions_and_Standards.md#c-code-style. +# -modernize-concat-nested-namespaces: We don't use it. +# -modernize-use-trailing-return-type: Stylistic preference we do not enforce. +# -readability-identifier-length: A lot of numerical code rely on short names to improve readability. +# -readability-uppercase-literal-suffix: We accept lowercase suffixes + +Checks: > + -*, + cppcoreguidelines-*, + google-*, + readability-*, + modernize-*, + bugprone-*, + performance-*, + misc-*, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-pro-type-reinterpret-cast, + -google-readability-todo, + -google-runtime-references, + -modernize-concat-nested-namespaces, + -modernize-use-trailing-return-type, + -readability-identifier-length, + -readability-uppercase-literal-suffix, +WarningsAsErrors: "" HeaderFilterRegex: '.*onnxruntime\/core\/.*' AnalyzeTemporaryDtors: false -FormatStyle: none -CheckOptions: - - key: google-readability-braces-around-statements.ShortStatementLines - value: '1' - - key: google-readability-function-size.StatementThreshold - value: '800' - - key: google-readability-namespace-comments.ShortNamespaceLines - value: '10' - - key: google-readability-namespace-comments.SpacesBeforeComments - value: '2' - - key: modernize-loop-convert.MaxCopySize - value: '16' - - key: modernize-loop-convert.MinConfidence - value: reasonable - - key: modernize-loop-convert.NamingStyle - value: CamelCase - - key: modernize-pass-by-value.IncludeStyle - value: google - - key: modernize-replace-auto-ptr.IncludeStyle - value: google - - key: modernize-use-nullptr.NullMacros - value: 'NULL' -... - +FormatStyle: none +CheckOptions: + - key: google-readability-braces-around-statements.ShortStatementLines + value: "1" + - key: google-readability-function-size.StatementThreshold + value: "800" + - key: google-readability-namespace-comments.ShortNamespaceLines + value: "10" + - key: google-readability-namespace-comments.SpacesBeforeComments + value: "2" + - key: modernize-loop-convert.MaxCopySize + value: "16" + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-pass-by-value.IncludeStyle + value: google + - key: modernize-replace-auto-ptr.IncludeStyle + value: google + - key: modernize-use-nullptr.NullMacros + value: "NULL" +--- diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 81d546ffa5fb0..15cbb4c766d31 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -81,6 +81,24 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + - name: Install ninja + run: python -m pip install --upgrade ninja + - name: Generate compile_commands.json + run: | + python tools/ci_build/build.py \ + --cmake_generator "Ninja" \ + --build_dir build \ + --update \ + --cmake_extra_defines CMAKE_EXPORT_COMPILE_COMMANDS=ON + - name: Generate ONNX protobuf files + run: cmake --build build/Debug --config Debug --target onnx_proto + - name: Run clang-tidy + uses: ZedThree/clang-tidy-review@526cbfb043719639f1ebdeedae0cc1eacd219d8f + with: + token: ${{ secrets.github_token }} + build_dir: "build/Debug" + config_file: ".clang-tidy" + lgtm_comment_body: "" - uses: reviewdog/action-cpplint@master with: github_token: ${{ secrets.github_token }}