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.

146 lines
5.0 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-yaml
  40. - id: end-of-file-fixer
  41. # NOTE Exclude tests directory: some test files have no
  42. # the trailing EOL in the file intentionally but some
  43. # just missed it.
  44. # TODO Add the missed trailing EOL in the following files
  45. # if possible.
  46. exclude: >-
  47. (?x)Tests/(
  48. DelphiCoverage/src/UTCovTest\.pas
  49. | FortranModules/in_interface/module\.f90
  50. | JavascriptCoverage/output\.json\.in
  51. | Module/ExternalData/Alt/(
  52. MyAlgoMap1-md5/dded55e43cd6529ee35d24113dfc87a3
  53. | SHA1/85158f0c1996837976e858c42a9a7634bfe91b93
  54. )
  55. | RunCMake/(
  56. CMP0055/CMP0055-(NEW|OLD)-Reject-Arguments\.cmake
  57. | CommandLine/E_cat_good_binary_cat-stdout\.txt
  58. | define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_[12]-result\.txt
  59. | FindMatlab/MatlabTest2-stderr\.txt
  60. | string/UTF-(16|32)LE\.txt
  61. | Syntax/BOM-UTF-(16|32)-LE.cmake
  62. | Syntax/CommandEOF\.cmake
  63. | VS10Project/shader2?\.hlsl
  64. )
  65. | SourceGroups/README\.txt
  66. | StringFileTest/test\.utf8
  67. | VSWindowsFormsResx/WindowsFormsResx/MyForm\.resx
  68. | VSXaml/Package\.appxmanifest
  69. )
  70. - id: mixed-line-ending
  71. - id: trailing-whitespace
  72. - repo: https://github.com/jumanjihouse/pre-commit-hooks
  73. rev: 3.0.0
  74. hooks:
  75. - id: git-check
  76. pass_filenames: false
  77. - repo: https://github.com/sphinx-contrib/sphinx-lint
  78. rev: v1.0.0
  79. hooks:
  80. - id: sphinx-lint
  81. # NOTE Looks like `bad-dedent` gives too many false-positives.
  82. args: ['--disable', 'bad-dedent']
  83. - repo: https://github.com/pre-commit/pygrep-hooks
  84. rev: v1.10.0
  85. hooks:
  86. - id: rst-backticks
  87. # NOTE The `productionlist` directive can give false-positives
  88. exclude: >-
  89. (?x)Help/(
  90. dev/maint\.rst
  91. | manual/cmake-(developer|language)\.7\.rst
  92. | variable/CMAKE_MESSAGE_CONTEXT\.rst
  93. )
  94. | Tests/CMakeLib/testRST\.rst
  95. - id: rst-directive-colons
  96. - id: rst-inline-touching-normal
  97. - repo: https://github.com/codespell-project/codespell
  98. rev: v2.4.0
  99. hooks:
  100. - id: codespell
  101. stages: [commit-msg, pre-commit]
  102. - repo: https://github.com/crate-ci/typos
  103. rev: v1.29.4
  104. hooks:
  105. - id: typos
  106. # NOTE Override hook's default args to prevent automatic
  107. # fixing of found typos. Let the dev decide what to fix!
  108. args: ['--force-exclude']
  109. stages: [commit-msg, pre-commit]
  110. - repo: https://github.com/pre-commit/mirrors-clang-format
  111. # ATTENTION CMake's `clang-format` is version 18.
  112. # DO NOT UPDATE THIS VERSION unless officially supported
  113. # `clang-format` get bumped.
  114. rev: v18.1.8
  115. hooks:
  116. - id: clang-format
  117. types_or: [c, c++, cuda]
  118. exclude_types: [objective-c++]
  119. # The following exclude list based on the output of:
  120. # $ git ls-files | git check-attr --stdin format.clang-format | grep ...
  121. # and
  122. # $ find -name .gitattributes -exec grep -Hn clang-format {} +
  123. exclude: >-
  124. (?x)(
  125. Source/LexerParser
  126. | Tests/(
  127. CSharpLinkFromCxx/UsefulManagedCppClass.*
  128. | CompileFeatures/cxx_right_angle_brackets\.cpp
  129. | PositionIndependentTargets/pic_test\.h
  130. | RunCMake/(
  131. CommandLine/cmake_depends/test_UTF-16LE\.h
  132. | CXXModules/examples/circular/circular-[ab]\.cppm
  133. | GenerateExportHeader/reference
  134. )
  135. | VSWinStorePhone/Direct3DApp1/Direct3DApp1\.cpp
  136. )
  137. )