You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
5.1 KiB

  1. # Read the docs here: https://pre-commit.com
  2. # List of some available hooks: https://pre-commit.com/hooks.html
  3. #
  4. # Install `pre-commit`:
  5. #
  6. # $ pip install pre-commit
  7. #
  8. # Install hooks to your clone:
  9. # $ pre-commit install
  10. #
  11. default_stages: [pre-commit]
  12. default_install_hook_types: [commit-msg, pre-commit]
  13. fail_fast: false
  14. # NOTE Exclude third-party sources and some files globally.
  15. # See `Utilities/Scripts/update-*.bash` scripts and
  16. # https://pre-commit.com/#regular-expressions
  17. exclude: >-
  18. (?x)Auxiliary/vim
  19. | Licenses/.*\.txt$
  20. | Source/(CursesDialog/form|kwsys)
  21. | Utilities/(cm.*|GitSetup|KWIML)
  22. | .*\.patch$
  23. repos:
  24. - repo: meta
  25. hooks:
  26. - id: check-hooks-apply
  27. - id: check-useless-excludes
  28. - repo: https://github.com/pre-commit/pre-commit-hooks
  29. rev: v5.0.0
  30. hooks:
  31. - id: check-case-conflict
  32. - id: check-json
  33. # NOTE Some tests have intentionally broken JSONs.
  34. exclude: >-
  35. (?x)Tests/(
  36. CMakeLib/testCTestResourceSpec_data/spec13
  37. | RunCMake/CTestResourceAllocation/invalid
  38. )\.json
  39. - id: check-toml
  40. - id: check-yaml
  41. - id: end-of-file-fixer
  42. # NOTE Exclude tests directory: some test files have no
  43. # the trailing EOL in the file intentionally but some
  44. # just missed it.
  45. # TODO Add the missed trailing EOL in the following files
  46. # if possible.
  47. exclude: >-
  48. (?x)Tests/(
  49. DelphiCoverage/src/UTCovTest\.pas
  50. | FortranModules/in_interface/module\.f90
  51. | JavascriptCoverage/output\.json\.in
  52. | Module/ExternalData/Alt/(
  53. MyAlgoMap1-md5/dded55e43cd6529ee35d24113dfc87a3
  54. | SHA1/85158f0c1996837976e858c42a9a7634bfe91b93
  55. )
  56. | RunCMake/(
  57. CMP0055/CMP0055-(NEW|OLD)-Reject-Arguments\.cmake
  58. | CommandLine/E_cat_good_binary_cat-stdout\.txt
  59. | define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_[12]-result\.txt
  60. | FindMatlab/MatlabTest2-stderr\.txt
  61. | string/UTF-(16|32)LE\.txt
  62. | Syntax/BOM-UTF-(16|32)-LE.cmake
  63. | Syntax/CommandEOF\.cmake
  64. | VS10Project/shader2?\.hlsl
  65. )
  66. | SourceGroups/README\.txt
  67. | StringFileTest/test\.utf8
  68. | VSWindowsFormsResx/WindowsFormsResx/MyForm\.resx
  69. | VSXaml/Package\.appxmanifest
  70. )
  71. - id: mixed-line-ending
  72. - id: trailing-whitespace
  73. - repo: https://github.com/jumanjihouse/pre-commit-hooks
  74. rev: 3.0.0
  75. hooks:
  76. - id: git-check
  77. pass_filenames: false
  78. - repo: https://github.com/sphinx-contrib/sphinx-lint
  79. rev: v1.0.0
  80. hooks:
  81. - id: sphinx-lint
  82. # NOTE Looks like `bad-dedent` gives too many false-positives.
  83. args: ['--disable', 'bad-dedent']
  84. - repo: https://github.com/pre-commit/pygrep-hooks
  85. rev: v1.10.0
  86. hooks:
  87. - id: rst-backticks
  88. # NOTE The `productionlist` directive can give false-positives
  89. exclude: >-
  90. (?x)Help/(
  91. dev/maint\.rst
  92. | manual/cmake-(developer|language)\.7\.rst
  93. | variable/CMAKE_MESSAGE_CONTEXT\.rst
  94. )
  95. | Tests/CMakeLib/testRST\.rst
  96. - id: rst-directive-colons
  97. - id: rst-inline-touching-normal
  98. - repo: https://github.com/codespell-project/codespell
  99. rev: v2.4.1
  100. hooks:
  101. - id: codespell
  102. stages: [commit-msg, pre-commit]
  103. # NOTE See BUG https://github.com/crate-ci/typos/issues/390
  104. - repo: https://github.com/adhtruong/mirrors-typos
  105. rev: v1.33.1
  106. hooks:
  107. - id: typos
  108. # NOTE Override hook's default args to prevent automatic
  109. # fixing of found typos. Let the dev decide what to fix!
  110. args: ['--force-exclude']
  111. stages: [commit-msg, pre-commit]
  112. - repo: https://github.com/pre-commit/mirrors-clang-format
  113. # ATTENTION CMake's `clang-format` is version 18.
  114. # DO NOT UPDATE THIS VERSION unless officially supported
  115. # `clang-format` get bumped.
  116. rev: v18.1.8
  117. hooks:
  118. - id: clang-format
  119. types_or: [c, c++, cuda]
  120. exclude_types: [objective-c++]
  121. # The following exclude list based on the output of:
  122. # $ git ls-files | git check-attr --stdin format.clang-format | grep ...
  123. # and
  124. # $ find -name .gitattributes -exec grep -Hn clang-format {} +
  125. exclude: >-
  126. (?x)(
  127. Source/LexerParser
  128. | Tests/(
  129. CSharpLinkFromCxx/UsefulManagedCppClass.*
  130. | CompileFeatures/cxx_right_angle_brackets\.cpp
  131. | PositionIndependentTargets/pic_test\.h
  132. | RunCMake/(
  133. CommandLine/cmake_depends/test_UTF-16LE\.h
  134. | CXXModules/examples/circular/circular-[ab]\.cppm
  135. | GenerateExportHeader/reference
  136. )
  137. | VSWinStorePhone/Direct3DApp1/Direct3DApp1\.cpp
  138. )
  139. )