overcommit 0.46.0 → 0.47.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f55e18f8852d00b8732b915daab20a7b37c28e60ee38dd35caacb091e0d87873
4
- data.tar.gz: c75636dd8144cb6022b0400d1d5e1615cc1c27e765d32432332ee7b2701b1f66
3
+ metadata.gz: 5cbfe83620ba468c0053d8303aa80350c50db1fe8a3d90028d0ae2794c219834
4
+ data.tar.gz: 9f3f6b7d8675cb83e65dc554d9ebe76de0f3287acfcb7f2161c3880ad315ceb9
5
5
  SHA512:
6
- metadata.gz: d8f0d7599c440d4389d19b94b558292f531d2832adf4846a104e2c033e3f0e12866b2f4febc444690ddc26fd245bd4146ff443c2fab5d49d2b44bec15b5befc8
7
- data.tar.gz: 977649b8287f01bb7871db881583eac0490b68687cb1ab671612bb1d41e116b3efe45d39dbdec30909ca8dd49da00a9678674b1d1512c7cf5e35d20e5f2ea99f
6
+ metadata.gz: a683f507f19caa0ab810b8b7635ddf4672d5daa3b2519090278bbc23da8e7662a3e1d95743dd61f2f12c1f308b1678fec6461c3d54bde8acfa4c89d2d03fc39b
7
+ data.tar.gz: 0b03b050b2e46d24e8d524de3d0b1b11c895173161d55f9e63224710191419a57f7d7bf8b8ae6e14f6d53f601ac2cecb85dd430e25105588e87b26b244047bc7
data/bin/overcommit CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # Check if Overcommit should invoke a Bundler context for loading gems
4
5
  require 'yaml'
data/config/default.yml CHANGED
@@ -230,6 +230,16 @@ PreCommit:
230
230
  install_command: 'npm install -g coffeelint'
231
231
  include: '**/*.coffee'
232
232
 
233
+ CookStyle:
234
+ enabled: false
235
+ description: 'Analyze with CookStyle'
236
+ required_executable: 'cookstyle'
237
+ flags: ['--format=emacs', '--force-exclusion', '--display-cop-names']
238
+ install_command: 'gem install cookstyle'
239
+ include:
240
+ - '**/*.rb'
241
+ - '**/*.erb'
242
+
233
243
  Credo:
234
244
  enabled: false
235
245
  description: 'Analyze with credo'
@@ -424,6 +434,13 @@ PreCommit:
424
434
  install_command: 'gem install json'
425
435
  include: '**/*.json'
426
436
 
437
+ KtLint:
438
+ enabled: false
439
+ description: 'Analyze with KtLint'
440
+ required_executable: 'ktlint'
441
+ flags: []
442
+ include: '**/*.kt'
443
+
427
444
  LicenseFinder:
428
445
  enabled: false
429
446
  description: 'Analyze with LicenseFinder'
@@ -612,7 +629,7 @@ PreCommit:
612
629
  enabled: false
613
630
  description: 'Analyze with Reek'
614
631
  required_executable: 'reek'
615
- flags: ['--single-line', '--no-color']
632
+ flags: ['--single-line', '--no-color', '--force-exclusion']
616
633
  install_command: 'gem install reek'
617
634
  include:
618
635
  - '**/*.gemspec'
@@ -722,12 +739,27 @@ PreCommit:
722
739
  - '**/*.css'
723
740
  - '**/*.less'
724
741
 
742
+ SwiftLint:
743
+ enabled: false
744
+ description: 'Analyze with SwiftLint'
745
+ required_executable: 'swiftlint'
746
+ flags: ['lint', '--strict']
747
+ install_command: 'brew install swiftlint'
748
+ include: '**/*.swift'
749
+
750
+ TerraformFormat:
751
+ enabled: false
752
+ description: 'Analyze with Terraform'
753
+ required_executable: 'terraform'
754
+ flags: ['fmt', '-check=true', '-diff=false']
755
+ include: '**/*.tf'
756
+
725
757
  TsLint:
726
- enabled: false
727
- description: 'Analyze with TSLint'
728
- required_executable: 'tslint'
729
- install_command: 'npm install -g tslint typescript'
730
- include: '**/*.ts'
758
+ enabled: false
759
+ description: 'Analyze with TSLint'
760
+ required_executable: 'tslint'
761
+ install_command: 'npm install -g tslint typescript'
762
+ include: '**/*.ts'
731
763
 
732
764
  TrailingWhitespace:
733
765
  enabled: false
@@ -769,7 +801,7 @@ PreCommit:
769
801
  description: 'Analyze with W3C HTML validation service'
770
802
  required_library: 'w3c_validators'
771
803
  install_command: 'gem install w3c_validators'
772
- validator_uri: 'http://validator.w3.org/check'
804
+ validator_uri: 'https://validator.w3.org/nu'
773
805
  charset: 'utf-8'
774
806
  doctype: 'HTML5'
775
807
  include:
@@ -1143,6 +1175,20 @@ PostRewrite:
1143
1175
  - 'package.json'
1144
1176
  - 'yarn.lock'
1145
1177
 
1178
+ # Hooks that run during the `prepare-commit-msg` hook.
1179
+ PrepareCommitMsg:
1180
+ ALL:
1181
+ requires_files: false
1182
+ required: false
1183
+ quiet: false
1184
+
1185
+ ReplaceBranch:
1186
+ enabled: false
1187
+ description: 'Prepends the commit message with text based on the branch name'
1188
+ branch_pattern: '\A.*\w+[-_](\d+).*\z'
1189
+ replacement_text: '[#\1]'
1190
+ on_fail: warn
1191
+
1146
1192
  # Hooks that run during `git push`, after remote refs have been updated but
1147
1193
  # before any objects have been transferred.
1148
1194
  PrePush:
data/lib/overcommit.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'overcommit/os'
2
4
  require 'overcommit/constants'
3
5
  require 'overcommit/exceptions'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit
2
4
  # Distributes a list of arguments over multiple invocations of a command.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'digest'
2
4
  require 'json'
3
5
 
@@ -41,7 +43,7 @@ module Overcommit
41
43
  @concurrency ||=
42
44
  begin
43
45
  cores = Overcommit::Utils.processor_count
44
- content = @hash.fetch('concurrency', '%<processors>d')
46
+ content = @hash.fetch('concurrency') { '%<processors>d' }
45
47
  if content.is_a?(String)
46
48
  concurrency_expr = content % { processors: cores }
47
49
 
@@ -154,7 +156,7 @@ module Overcommit
154
156
  # environment variables.
155
157
  def apply_environment!(hook_context, env)
156
158
  skipped_hooks = "#{env['SKIP']} #{env['SKIP_CHECKS']} #{env['SKIP_HOOKS']}".split(/[:, ]/)
157
- only_hooks = env.fetch('ONLY', '').split(/[:, ]/)
159
+ only_hooks = env.fetch('ONLY') { '' }.split(/[:, ]/)
158
160
  hook_type = hook_context.hook_class_name
159
161
 
160
162
  if only_hooks.any? || skipped_hooks.include?('all') || skipped_hooks.include?('ALL')
@@ -252,7 +254,7 @@ module Overcommit
252
254
  private
253
255
 
254
256
  def ad_hoc_hook?(hook_context, hook_name)
255
- ad_hoc_conf = @hash.fetch(hook_context.hook_class_name, {}).fetch(hook_name, {})
257
+ ad_hoc_conf = @hash.fetch(hook_context.hook_class_name) { {} }.fetch(hook_name) { {} }
256
258
 
257
259
  # Ad hoc hooks are neither built-in nor have a plugin file written but
258
260
  # still have a `command` specified to be run
@@ -282,7 +284,7 @@ module Overcommit
282
284
  hook_context_or_type.hook_class_name
283
285
  end
284
286
 
285
- individual_enabled = @hash[hook_type].fetch(hook_name, {})['enabled']
287
+ individual_enabled = @hash[hook_type].fetch(hook_name) { {} }['enabled']
286
288
  return individual_enabled unless individual_enabled.nil?
287
289
 
288
290
  all_enabled = @hash[hook_type]['ALL']['enabled']
@@ -65,7 +65,7 @@ module Overcommit
65
65
  config = self.class.load_from_file(file, default: false, logger: @log)
66
66
  config = self.class.default_configuration.merge(config)
67
67
 
68
- if @options.fetch(:verify, config.verify_signatures?)
68
+ if @options.fetch(:verify) { config.verify_signatures? }
69
69
  verify_signatures(config)
70
70
  end
71
71
 
@@ -1,4 +1,6 @@
1
- # rubocop:disable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/LineLength
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/MethodLength
2
4
  module Overcommit
3
5
  # Validates and normalizes a configuration.
4
6
  class ConfigurationValidator
@@ -57,8 +59,8 @@ module Overcommit
57
59
  errors = []
58
60
 
59
61
  Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
60
- hash.fetch(hook_type, {}).each do |hook_name, hook_config|
61
- hook_env = hook_config.fetch('env', {})
62
+ hash.fetch(hook_type) { {} }.each do |hook_name, hook_config|
63
+ hook_env = hook_config.fetch('env') { {} }
62
64
 
63
65
  unless hook_env.is_a?(Hash)
64
66
  errors << "#{hook_type}::#{hook_name} has an invalid `env` specified: " \
@@ -82,8 +84,10 @@ module Overcommit
82
84
  end
83
85
 
84
86
  if errors.any?
85
- @log.error errors.join("\n") if @log
86
- @log.newline if @log
87
+ if @log
88
+ @log.error errors.join("\n")
89
+ @log.newline
90
+ end
87
91
  raise Overcommit::Exceptions::ConfigurationError,
88
92
  'One or more hooks had an invalid `env` configuration option'
89
93
  end
@@ -95,7 +99,7 @@ module Overcommit
95
99
  errors = []
96
100
 
97
101
  Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
98
- hash.fetch(hook_type, {}).each_key do |hook_name|
102
+ hash.fetch(hook_type) { {} }.each_key do |hook_name|
99
103
  next if hook_name == 'ALL'
100
104
 
101
105
  unless hook_name =~ /\A[A-Za-z0-9]+\z/
@@ -107,8 +111,10 @@ module Overcommit
107
111
  end
108
112
 
109
113
  if errors.any?
110
- @log.error errors.join("\n") if @log
111
- @log.newline if @log
114
+ if @log
115
+ @log.error errors.join("\n")
116
+ @log.newline
117
+ end
112
118
  raise Overcommit::Exceptions::ConfigurationError,
113
119
  'One or more hooks had invalid names'
114
120
  end
@@ -122,7 +128,7 @@ module Overcommit
122
128
  any_warnings = false
123
129
 
124
130
  Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
125
- hash.fetch(hook_type, {}).each do |hook_name, hook_config|
131
+ hash.fetch(hook_type) { {} }.each do |hook_name, hook_config|
126
132
  next if hook_name == 'ALL'
127
133
 
128
134
  if hook_config['enabled'].nil?
@@ -143,8 +149,8 @@ module Overcommit
143
149
 
144
150
  errors = []
145
151
  Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
146
- hash.fetch(hook_type, {}).each do |hook_name, hook_config|
147
- processors = hook_config.fetch('processors', 1)
152
+ hash.fetch(hook_type) { {} }.each do |hook_name, hook_config|
153
+ processors = hook_config.fetch('processors') { 1 }
148
154
  if processors > concurrency
149
155
  errors << "#{hook_type}::#{hook_name} `processors` value " \
150
156
  "(#{processors}) is larger than the global `concurrency` " \
@@ -154,8 +160,10 @@ module Overcommit
154
160
  end
155
161
 
156
162
  if errors.any?
157
- @log.error errors.join("\n") if @log
158
- @log.newline if @log
163
+ if @log
164
+ @log.error errors.join("\n")
165
+ @log.newline
166
+ end
159
167
  raise Overcommit::Exceptions::ConfigurationError,
160
168
  'One or more hooks had invalid `processor` value configured'
161
169
  end
@@ -175,4 +183,4 @@ module Overcommit
175
183
  end
176
184
  end
177
185
  end
178
- # rubocop:enable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/LineLength
186
+ # rubocop:enable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/MethodLength
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Exceptions
2
4
  # Raised when a {Configuration} could not be loaded from a file.
3
5
  class ConfigurationError < StandardError; end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'overcommit/utils'
2
4
 
3
5
  module Overcommit
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'iniparse'
2
4
 
3
5
  module Overcommit
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Returns the version of the available git binary.
2
4
  #
3
5
  # This is intended to be used to conveniently execute code based on a specific
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
  require 'overcommit/message_processor'
3
5
 
@@ -42,7 +44,7 @@ module Overcommit::Hook
42
44
  if output = check_for_requirements
43
45
  status = :fail
44
46
  else
45
- result = Overcommit::Utils.with_environment(@config.fetch('env', {})) { run }
47
+ result = Overcommit::Utils.with_environment(@config.fetch('env') { {} }) { run }
46
48
  status, output = process_hook_return_value(result)
47
49
  end
48
50
 
@@ -66,7 +68,7 @@ module Overcommit::Hook
66
68
  end
67
69
 
68
70
  def processors
69
- @config.fetch('processors', 1)
71
+ @config.fetch('processors') { 1 }
70
72
  end
71
73
 
72
74
  def quiet?
@@ -270,9 +272,9 @@ module Overcommit::Hook
270
272
  def transform_status(status)
271
273
  case status
272
274
  when :fail
273
- @config.fetch('on_fail', :fail).to_sym
275
+ @config.fetch('on_fail') { :fail }.to_sym
274
276
  when :warn
275
- @config.fetch('on_warn', :warn).to_sym
277
+ @config.fetch('on_warn') { :warn }.to_sym
276
278
  else
277
279
  status
278
280
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
 
3
5
  module Overcommit::Hook::CommitMsg
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Ensures commit message subject lines start with a capital letter.
3
5
  class CapitalizedSubject < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Checks that the commit message is not empty
3
5
  class EmptyMessage < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Ensures a Gerrit Change-Id line is included in the commit message.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Checks for hard tabs in commit messages.
3
5
  class HardTabs < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Ensures the commit message follows a specific format.
3
5
  class MessageFormat < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Checks for long commit messages (not good or bad--just fun to point out)
3
5
  class RussianNovel < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Ensures commit message subject lines are followed by a blank line.
3
5
  class SingleLineSubject < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tempfile'
2
4
 
3
5
  module Overcommit::Hook::CommitMsg
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Ensures the number of columns the subject and commit message lines occupy is
3
5
  # under the preferred limits.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit::Hook::CommitMsg
2
4
  # Ensures commit message subject lines do not have a trailing period
3
5
  class TrailingPeriod < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
 
3
5
  module Overcommit::Hook::PostCheckout
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'overcommit/hook/shared/bower_install'
2
4
 
3
5
  module Overcommit::Hook::PostCheckout
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'overcommit/hook/shared/bundle_install'
2
4
 
3
5
  module Overcommit::Hook::PostCheckout
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'overcommit/hook/shared/composer_install'
2
4
 
3
5
  module Overcommit::Hook::PostCheckout