.pre-commit-config.yaml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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: v6.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/(
  63. OneCharacter
  64. | (Broken-)?BOM-UTF-(16|32)-[BL]E
  65. | CommandEOF
  66. )\.cmake
  67. | VS10Project/shader2?\.hlsl
  68. )
  69. | SourceGroups/README\.txt
  70. | StringFileTest/test\.utf8
  71. | VSWindowsFormsResx/WindowsFormsResx/MyForm\.resx
  72. | VSXaml/Package\.appxmanifest
  73. )
  74. - id: mixed-line-ending
  75. - id: trailing-whitespace
  76. - repo: https://github.com/jumanjihouse/pre-commit-hooks
  77. rev: 3.0.0
  78. hooks:
  79. - id: git-check
  80. pass_filenames: false
  81. - repo: https://github.com/sphinx-contrib/sphinx-lint
  82. rev: v1.0.2
  83. hooks:
  84. - id: sphinx-lint
  85. # NOTE Looks like `bad-dedent` gives too many false-positives.
  86. args: ['--disable', 'bad-dedent']
  87. - repo: https://github.com/pre-commit/pygrep-hooks
  88. rev: v1.10.0
  89. hooks:
  90. - id: rst-backticks
  91. # NOTE The `productionlist` directive can give false-positives
  92. exclude: >-
  93. (?x)Help/(
  94. dev/maint\.rst
  95. | manual/cmake-(developer|language)\.7\.rst
  96. | variable/CMAKE_MESSAGE_CONTEXT\.rst
  97. )
  98. | Tests/CMakeLib/testRST\.rst
  99. - id: rst-directive-colons
  100. - id: rst-inline-touching-normal
  101. - repo: https://github.com/codespell-project/codespell
  102. rev: v2.4.1
  103. hooks:
  104. - id: codespell
  105. stages: [commit-msg, pre-commit]
  106. # NOTE See BUG https://github.com/crate-ci/typos/issues/390
  107. - repo: https://github.com/adhtruong/mirrors-typos
  108. rev: v1.44.0
  109. hooks:
  110. - id: typos
  111. # NOTE Override hook's default args to prevent automatic
  112. # fixing of found typos. Let the dev decide what to fix!
  113. args: ['--force-exclude']
  114. stages: [commit-msg, pre-commit]
  115. - repo: https://github.com/pre-commit/mirrors-clang-format
  116. # ATTENTION CMake's `clang-format` is version 18.
  117. # DO NOT UPDATE THIS VERSION unless officially supported
  118. # `clang-format` get bumped.
  119. rev: v18.1.8
  120. hooks:
  121. - id: clang-format
  122. types_or: [c, c++, cuda]
  123. exclude_types: [objective-c++]
  124. # The following exclude list based on the output of:
  125. # $ git ls-files | git check-attr --stdin format.clang-format | grep ...
  126. # and
  127. # $ find -name .gitattributes -exec grep -Hn clang-format {} +
  128. exclude: >-
  129. (?x)(
  130. Source/LexerParser
  131. | Tests/(
  132. CSharpLinkFromCxx/UsefulManagedCppClass.*
  133. | CompileFeatures/cxx_right_angle_brackets\.cpp
  134. | PositionIndependentTargets/pic_test\.h
  135. | RunCMake/(
  136. CommandLine/cmake_depends/test_UTF-16LE\.h
  137. | CXXModules/examples/circular/circular-[ab]\.cppm
  138. | GenerateExportHeader/reference
  139. )
  140. | VSWinStorePhone/Direct3DApp1/Direct3DApp1\.cpp
  141. )
  142. )