overcommit 0.46.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/bin/overcommit +1 -0
  3. data/config/default.yml +53 -7
  4. data/lib/overcommit.rb +2 -0
  5. data/lib/overcommit/command_splitter.rb +2 -0
  6. data/lib/overcommit/configuration.rb +6 -4
  7. data/lib/overcommit/configuration_loader.rb +1 -1
  8. data/lib/overcommit/configuration_validator.rb +22 -14
  9. data/lib/overcommit/exceptions.rb +2 -0
  10. data/lib/overcommit/git_config.rb +2 -0
  11. data/lib/overcommit/git_repo.rb +2 -0
  12. data/lib/overcommit/git_version.rb +2 -0
  13. data/lib/overcommit/hook/base.rb +6 -4
  14. data/lib/overcommit/hook/commit_msg/base.rb +2 -0
  15. data/lib/overcommit/hook/commit_msg/capitalized_subject.rb +2 -0
  16. data/lib/overcommit/hook/commit_msg/empty_message.rb +2 -0
  17. data/lib/overcommit/hook/commit_msg/gerrit_change_id.rb +2 -0
  18. data/lib/overcommit/hook/commit_msg/hard_tabs.rb +2 -0
  19. data/lib/overcommit/hook/commit_msg/message_format.rb +2 -0
  20. data/lib/overcommit/hook/commit_msg/russian_novel.rb +2 -0
  21. data/lib/overcommit/hook/commit_msg/single_line_subject.rb +2 -0
  22. data/lib/overcommit/hook/commit_msg/spell_check.rb +2 -0
  23. data/lib/overcommit/hook/commit_msg/text_width.rb +2 -0
  24. data/lib/overcommit/hook/commit_msg/trailing_period.rb +2 -0
  25. data/lib/overcommit/hook/post_checkout/base.rb +2 -0
  26. data/lib/overcommit/hook/post_checkout/bower_install.rb +2 -0
  27. data/lib/overcommit/hook/post_checkout/bundle_install.rb +2 -0
  28. data/lib/overcommit/hook/post_checkout/composer_install.rb +2 -0
  29. data/lib/overcommit/hook/post_checkout/index_tags.rb +2 -0
  30. data/lib/overcommit/hook/post_checkout/npm_install.rb +2 -0
  31. data/lib/overcommit/hook/post_checkout/submodule_status.rb +2 -0
  32. data/lib/overcommit/hook/post_checkout/yarn_install.rb +2 -0
  33. data/lib/overcommit/hook/post_commit/base.rb +2 -0
  34. data/lib/overcommit/hook/post_commit/bower_install.rb +2 -0
  35. data/lib/overcommit/hook/post_commit/bundle_install.rb +2 -0
  36. data/lib/overcommit/hook/post_commit/commitplease.rb +2 -0
  37. data/lib/overcommit/hook/post_commit/composer_install.rb +2 -0
  38. data/lib/overcommit/hook/post_commit/git_guilt.rb +2 -0
  39. data/lib/overcommit/hook/post_commit/index_tags.rb +2 -0
  40. data/lib/overcommit/hook/post_commit/npm_install.rb +2 -0
  41. data/lib/overcommit/hook/post_commit/submodule_status.rb +2 -0
  42. data/lib/overcommit/hook/post_commit/yarn_install.rb +2 -0
  43. data/lib/overcommit/hook/post_merge/base.rb +2 -0
  44. data/lib/overcommit/hook/post_merge/bower_install.rb +2 -0
  45. data/lib/overcommit/hook/post_merge/bundle_install.rb +2 -0
  46. data/lib/overcommit/hook/post_merge/composer_install.rb +2 -0
  47. data/lib/overcommit/hook/post_merge/index_tags.rb +2 -0
  48. data/lib/overcommit/hook/post_merge/npm_install.rb +2 -0
  49. data/lib/overcommit/hook/post_merge/submodule_status.rb +2 -0
  50. data/lib/overcommit/hook/post_merge/yarn_install.rb +2 -0
  51. data/lib/overcommit/hook/post_rewrite/base.rb +2 -0
  52. data/lib/overcommit/hook/post_rewrite/bower_install.rb +2 -0
  53. data/lib/overcommit/hook/post_rewrite/bundle_install.rb +2 -0
  54. data/lib/overcommit/hook/post_rewrite/composer_install.rb +2 -0
  55. data/lib/overcommit/hook/post_rewrite/index_tags.rb +2 -0
  56. data/lib/overcommit/hook/post_rewrite/npm_install.rb +2 -0
  57. data/lib/overcommit/hook/post_rewrite/submodule_status.rb +2 -0
  58. data/lib/overcommit/hook/post_rewrite/yarn_install.rb +2 -0
  59. data/lib/overcommit/hook/pre_commit/author_email.rb +2 -0
  60. data/lib/overcommit/hook/pre_commit/author_name.rb +2 -0
  61. data/lib/overcommit/hook/pre_commit/base.rb +2 -0
  62. data/lib/overcommit/hook/pre_commit/broken_symlinks.rb +2 -0
  63. data/lib/overcommit/hook/pre_commit/bundle_audit.rb +2 -0
  64. data/lib/overcommit/hook/pre_commit/bundle_check.rb +2 -1
  65. data/lib/overcommit/hook/pre_commit/bundle_outdated.rb +2 -0
  66. data/lib/overcommit/hook/pre_commit/case_conflicts.rb +2 -0
  67. data/lib/overcommit/hook/pre_commit/chamber_compare.rb +2 -0
  68. data/lib/overcommit/hook/pre_commit/chamber_security.rb +2 -0
  69. data/lib/overcommit/hook/pre_commit/chamber_verification.rb +3 -1
  70. data/lib/overcommit/hook/pre_commit/coffee_lint.rb +2 -0
  71. data/lib/overcommit/hook/pre_commit/cook_style.rb +35 -0
  72. data/lib/overcommit/hook/pre_commit/credo.rb +2 -0
  73. data/lib/overcommit/hook/pre_commit/css_lint.rb +2 -0
  74. data/lib/overcommit/hook/pre_commit/dogma.rb +2 -0
  75. data/lib/overcommit/hook/pre_commit/es_lint.rb +2 -0
  76. data/lib/overcommit/hook/pre_commit/execute_permissions.rb +2 -0
  77. data/lib/overcommit/hook/pre_commit/fasterer.rb +2 -0
  78. data/lib/overcommit/hook/pre_commit/fix_me.rb +2 -0
  79. data/lib/overcommit/hook/pre_commit/flay.rb +2 -0
  80. data/lib/overcommit/hook/pre_commit/foodcritic.rb +2 -0
  81. data/lib/overcommit/hook/pre_commit/forbidden_branches.rb +2 -0
  82. data/lib/overcommit/hook/pre_commit/go_lint.rb +2 -0
  83. data/lib/overcommit/hook/pre_commit/go_vet.rb +2 -0
  84. data/lib/overcommit/hook/pre_commit/hadolint.rb +2 -0
  85. data/lib/overcommit/hook/pre_commit/haml_lint.rb +2 -0
  86. data/lib/overcommit/hook/pre_commit/hard_tabs.rb +2 -0
  87. data/lib/overcommit/hook/pre_commit/hlint.rb +2 -0
  88. data/lib/overcommit/hook/pre_commit/html_hint.rb +2 -0
  89. data/lib/overcommit/hook/pre_commit/html_tidy.rb +2 -0
  90. data/lib/overcommit/hook/pre_commit/image_optim.rb +2 -0
  91. data/lib/overcommit/hook/pre_commit/java_checkstyle.rb +2 -0
  92. data/lib/overcommit/hook/pre_commit/js_hint.rb +2 -0
  93. data/lib/overcommit/hook/pre_commit/js_lint.rb +2 -0
  94. data/lib/overcommit/hook/pre_commit/jscs.rb +2 -0
  95. data/lib/overcommit/hook/pre_commit/jsl.rb +2 -0
  96. data/lib/overcommit/hook/pre_commit/json_syntax.rb +2 -0
  97. data/lib/overcommit/hook/pre_commit/kt_lint.rb +19 -0
  98. data/lib/overcommit/hook/pre_commit/license_finder.rb +2 -0
  99. data/lib/overcommit/hook/pre_commit/license_header.rb +2 -0
  100. data/lib/overcommit/hook/pre_commit/line_endings.rb +2 -0
  101. data/lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb +2 -0
  102. data/lib/overcommit/hook/pre_commit/mdl.rb +2 -0
  103. data/lib/overcommit/hook/pre_commit/merge_conflicts.rb +2 -0
  104. data/lib/overcommit/hook/pre_commit/nginx_test.rb +2 -0
  105. data/lib/overcommit/hook/pre_commit/pep257.rb +2 -0
  106. data/lib/overcommit/hook/pre_commit/pep8.rb +2 -0
  107. data/lib/overcommit/hook/pre_commit/php_cs.rb +2 -0
  108. data/lib/overcommit/hook/pre_commit/php_cs_fixer.rb +2 -0
  109. data/lib/overcommit/hook/pre_commit/php_lint.rb +2 -0
  110. data/lib/overcommit/hook/pre_commit/php_stan.rb +2 -0
  111. data/lib/overcommit/hook/pre_commit/pronto.rb +2 -0
  112. data/lib/overcommit/hook/pre_commit/puppet_lint.rb +2 -0
  113. data/lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb +2 -0
  114. data/lib/overcommit/hook/pre_commit/pycodestyle.rb +2 -0
  115. data/lib/overcommit/hook/pre_commit/pydocstyle.rb +2 -0
  116. data/lib/overcommit/hook/pre_commit/pyflakes.rb +2 -0
  117. data/lib/overcommit/hook/pre_commit/pylint.rb +2 -0
  118. data/lib/overcommit/hook/pre_commit/python_flake8.rb +2 -0
  119. data/lib/overcommit/hook/pre_commit/rails_best_practices.rb +2 -0
  120. data/lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb +2 -0
  121. data/lib/overcommit/hook/pre_commit/rake_target.rb +2 -0
  122. data/lib/overcommit/hook/pre_commit/reek.rb +2 -0
  123. data/lib/overcommit/hook/pre_commit/rst_lint.rb +2 -0
  124. data/lib/overcommit/hook/pre_commit/rubo_cop.rb +2 -0
  125. data/lib/overcommit/hook/pre_commit/ruby_lint.rb +2 -0
  126. data/lib/overcommit/hook/pre_commit/scalariform.rb +2 -0
  127. data/lib/overcommit/hook/pre_commit/scalastyle.rb +2 -0
  128. data/lib/overcommit/hook/pre_commit/scss_lint.rb +2 -0
  129. data/lib/overcommit/hook/pre_commit/semi_standard.rb +2 -0
  130. data/lib/overcommit/hook/pre_commit/shell_check.rb +2 -0
  131. data/lib/overcommit/hook/pre_commit/slim_lint.rb +2 -0
  132. data/lib/overcommit/hook/pre_commit/sqlint.rb +2 -0
  133. data/lib/overcommit/hook/pre_commit/standard.rb +2 -0
  134. data/lib/overcommit/hook/pre_commit/stylelint.rb +2 -0
  135. data/lib/overcommit/hook/pre_commit/swift_lint.rb +19 -0
  136. data/lib/overcommit/hook/pre_commit/terraform_format.rb +19 -0
  137. data/lib/overcommit/hook/pre_commit/trailing_whitespace.rb +2 -0
  138. data/lib/overcommit/hook/pre_commit/travis_lint.rb +2 -0
  139. data/lib/overcommit/hook/pre_commit/ts_lint.rb +14 -4
  140. data/lib/overcommit/hook/pre_commit/vint.rb +2 -0
  141. data/lib/overcommit/hook/pre_commit/w3c_css.rb +2 -0
  142. data/lib/overcommit/hook/pre_commit/w3c_html.rb +2 -0
  143. data/lib/overcommit/hook/pre_commit/xml_lint.rb +2 -0
  144. data/lib/overcommit/hook/pre_commit/xml_syntax.rb +2 -0
  145. data/lib/overcommit/hook/pre_commit/yaml_lint.rb +2 -0
  146. data/lib/overcommit/hook/pre_commit/yaml_syntax.rb +2 -0
  147. data/lib/overcommit/hook/pre_commit/yard_coverage.rb +2 -0
  148. data/lib/overcommit/hook/pre_commit/yarn_check.rb +1 -1
  149. data/lib/overcommit/hook/pre_push/base.rb +2 -0
  150. data/lib/overcommit/hook/pre_push/brakeman.rb +2 -0
  151. data/lib/overcommit/hook/pre_push/cargo_test.rb +2 -0
  152. data/lib/overcommit/hook/pre_push/minitest.rb +2 -0
  153. data/lib/overcommit/hook/pre_push/php_unit.rb +2 -0
  154. data/lib/overcommit/hook/pre_push/protected_branches.rb +2 -0
  155. data/lib/overcommit/hook/pre_push/pytest.rb +2 -0
  156. data/lib/overcommit/hook/pre_push/python_nose.rb +2 -0
  157. data/lib/overcommit/hook/pre_push/r_spec.rb +2 -0
  158. data/lib/overcommit/hook/pre_push/rake_target.rb +2 -0
  159. data/lib/overcommit/hook/pre_push/test_unit.rb +2 -0
  160. data/lib/overcommit/hook/pre_rebase/base.rb +2 -0
  161. data/lib/overcommit/hook/pre_rebase/merged_commits.rb +2 -0
  162. data/lib/overcommit/hook/prepare_commit_msg/base.rb +25 -0
  163. data/lib/overcommit/hook/prepare_commit_msg/replace_branch.rb +52 -0
  164. data/lib/overcommit/hook/shared/bower_install.rb +2 -0
  165. data/lib/overcommit/hook/shared/bundle_install.rb +2 -0
  166. data/lib/overcommit/hook/shared/composer_install.rb +2 -0
  167. data/lib/overcommit/hook/shared/index_tags.rb +2 -0
  168. data/lib/overcommit/hook/shared/npm_install.rb +2 -0
  169. data/lib/overcommit/hook/shared/rake_target.rb +2 -0
  170. data/lib/overcommit/hook/shared/submodule_status.rb +2 -0
  171. data/lib/overcommit/hook/shared/yarn_install.rb +2 -0
  172. data/lib/overcommit/hook_context.rb +2 -0
  173. data/lib/overcommit/hook_context/base.rb +2 -0
  174. data/lib/overcommit/hook_context/commit_msg.rb +2 -0
  175. data/lib/overcommit/hook_context/post_checkout.rb +2 -0
  176. data/lib/overcommit/hook_context/post_commit.rb +2 -0
  177. data/lib/overcommit/hook_context/post_merge.rb +2 -0
  178. data/lib/overcommit/hook_context/post_rewrite.rb +2 -0
  179. data/lib/overcommit/hook_context/pre_commit.rb +4 -1
  180. data/lib/overcommit/hook_context/pre_push.rb +2 -0
  181. data/lib/overcommit/hook_context/pre_rebase.rb +2 -0
  182. data/lib/overcommit/hook_context/prepare_commit_msg.rb +34 -0
  183. data/lib/overcommit/hook_context/run_all.rb +2 -0
  184. data/lib/overcommit/hook_loader/base.rb +2 -0
  185. data/lib/overcommit/hook_loader/built_in_hook_loader.rb +2 -0
  186. data/lib/overcommit/hook_loader/plugin_hook_loader.rb +2 -0
  187. data/lib/overcommit/hook_runner.rb +2 -0
  188. data/lib/overcommit/hook_signer.rb +2 -0
  189. data/lib/overcommit/installer.rb +2 -0
  190. data/lib/overcommit/interrupt_handler.rb +2 -0
  191. data/lib/overcommit/logger.rb +3 -1
  192. data/lib/overcommit/os.rb +2 -0
  193. data/lib/overcommit/printer.rb +2 -0
  194. data/lib/overcommit/subprocess.rb +2 -0
  195. data/lib/overcommit/utils.rb +3 -1
  196. data/lib/overcommit/utils/file_utils.rb +2 -0
  197. data/lib/overcommit/utils/messages_utils.rb +2 -0
  198. data/lib/overcommit/version.rb +1 -1
  199. data/template-dir/hooks/commit-msg +1 -0
  200. data/template-dir/hooks/overcommit-hook +1 -0
  201. data/template-dir/hooks/post-checkout +1 -0
  202. data/template-dir/hooks/post-commit +1 -0
  203. data/template-dir/hooks/post-merge +1 -0
  204. data/template-dir/hooks/post-rewrite +1 -0
  205. data/template-dir/hooks/pre-commit +1 -0
  206. data/template-dir/hooks/pre-push +1 -0
  207. data/template-dir/hooks/pre-rebase +1 -0
  208. data/template-dir/hooks/prepare-commit-msg +116 -0
  209. metadata +11 -4
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `haml-lint` against any modified HAML files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Checks for hard tabs in files.
3
5
  class HardTabs < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `hlint` against any modified Haskell files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `htmlhint` against any modified HTML files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `tidy` against any modified HTML files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Checks for images that can be optimized with `image_optim`.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `checkstyle` against any modified Java files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `jshint` against any modified JavaScript files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `jslint` against any modified JavaScript files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `jscs` (JavaScript Code Style Checker) against any modified JavaScript
3
5
  # files.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `jsl` against any modified JavaScript files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Checks the syntax of any modified JSON files.
3
5
  class JsonSyntax < Base
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Overcommit::Hook::PreCommit
4
+ # Runs `ktlint` against modified Kotlin files.
5
+ # @see https://github.com/shyiko/ktlint
6
+ class KtLint < Base
7
+ MESSAGE_REGEX = /((?<file>[^:]+):(?<line>\d+):(\d+):(?<message>.+))/
8
+
9
+ def run
10
+ result = execute(command, args: applicable_files)
11
+ return :pass if result.success?
12
+
13
+ extract_messages(
14
+ result.stdout.split("\n").grep(MESSAGE_REGEX),
15
+ MESSAGE_REGEX
16
+ )
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs LicenseFinder if any of your package manager declaration files have changed
3
5
  # See more about LicenseFinder at https://github.com/pivotal/LicenseFinder
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Checks for license headers in source files
3
5
  class LicenseHeader < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Checks for line endings in files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Checks for local paths in files and issues a warning
3
5
  class LocalPathsInGemfile < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `mdl` against any modified Markdown files
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Checks for unresolved merge conflicts
3
5
  class MergeConflicts < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `nginx -t` against any modified Nginx config files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `pep257` against any modified Python files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `pep8` against any modified Python files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `phpcs` against any modified PHP files.
3
5
  class PhpCs < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `php-cs-fixer` against any modified PHP files.
3
5
  class PhpCsFixer < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `php -l` against any modified PHP files.
3
5
  class PhpLint < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `phpstan` against any modified PHP files.
3
5
  # For running `phpstan` with Laravel, it requires setup with `ide_helper`.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `pronto`
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs 'puppet-lint' against any modified Puppet files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  #
3
5
  # Run's the Puppet metadata linter. It has support for adding options
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `pycodestyle` against any modified Python files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `pydocstyle` against any modified Python files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `pyflakes` against any modified Python files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `pylint` against any modified Python files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `flake8` against any modified Python files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit
2
4
  module Hook
3
5
  module PreCommit
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Check to see whether the schema file is in line with the migrations. When a
3
5
  # schema file is present but a migration file is not, this is usually a
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'overcommit/hook/shared/rake_target'
2
4
 
3
5
  module Overcommit::Hook::PreCommit
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `reek` against any modified Ruby files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `rst-lint` against any modified reStructuredText files
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `rubocop` against any modified Ruby files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `ruby-lint` against any modified Ruby files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `scalariform` against any modified Scala files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `scalastyle` against any modified Scala files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `scss-lint` against any modified SCSS files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `semistandard` against any modified JavaScript files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `shellcheck` against any modified shell script files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `slim-lint` against any modified Slim templates.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs 'sqlint' against any modified SQL files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `standard` against any modified JavaScript files.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `stylelint` against any modified CSS file.
3
5
  #
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Overcommit::Hook::PreCommit
4
+ # Runs `swiftlint lint` against modified Swift files.
5
+ # @see https://github.com/realm/SwiftLint
6
+ class SwiftLint < Base
7
+ MESSAGE_REGEX = /^(?<file>(?:\w:)?[^:]+):(?<line>\d+)[^ ]* (?<type>[^ ]+):(?<message>.*)/
8
+
9
+ def run
10
+ result = execute(command, args: applicable_files)
11
+ return :pass if result.success?
12
+
13
+ extract_messages(
14
+ result.stdout.split("\n").grep(MESSAGE_REGEX),
15
+ MESSAGE_REGEX
16
+ )
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Overcommit::Hook::PreCommit
4
+ # Runs 'terraform fmt' against any modified *.tf files.
5
+ #
6
+ # @see https://www.terraform.io/docs/commands/fmt.html
7
+ class TerraformFormat < Base
8
+ def run
9
+ messages = []
10
+ applicable_files.each do |f|
11
+ result = execute(command, args: [f])
12
+ unless result.success?
13
+ messages << Overcommit::Hook::Message.new(:error, f, nil, "violation found in #{f}")
14
+ end
15
+ end
16
+ messages
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Checks for trailing whitespace in files.
3
5
  class TrailingWhitespace < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `travis-lint` against any modified Travis CI files.
3
5
  #
@@ -1,17 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::PreCommit
2
4
  # Runs `tslint` against modified TypeScript files.
3
5
  # @see http://palantir.github.io/tslint/
4
6
  class TsLint < Base
7
+ # example message:
8
+ # "src/file/anotherfile.ts[298, 1]: exceeds maximum line length of 140"
9
+ # or
10
+ # "ERROR: src/AccountController.ts[4, 28]: expected call-signature to have a typedef"
11
+ MESSAGE_REGEX = /^(?<type>.+: )?(?<file>.+?(?=\[))[^\d]+(?<line>\d+).*?/
12
+
5
13
  def run
6
14
  result = execute(command, args: applicable_files)
7
15
  output = result.stdout.chomp
8
16
  return :pass if result.success? && output.empty?
9
17
 
10
- # example message:
11
- # src/file/anotherfile.ts[298, 1]: exceeds maximum line length of 140
18
+ output_lines = output.split("\n").map(&:strip).reject(&:empty?)
19
+ type_categorizer = ->(type) { type.nil? || type.include?('ERROR') ? :error : :warning }
20
+
12
21
  extract_messages(
13
- output.split("\n"),
14
- /^(?<file>.+?(?=\[))[^\d]+(?<line>\d+).*?/
22
+ output_lines,
23
+ MESSAGE_REGEX,
24
+ type_categorizer
15
25
  )
16
26
  end
17
27
  end