overcommit 0.35.0 → 0.36.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +22 -0
- data/lib/overcommit/configuration_validator.rb +38 -0
- data/lib/overcommit/hook/pre_commit/fasterer.rb +23 -0
- data/lib/overcommit/hook/pre_commit/ts_lint.rb +18 -0
- data/lib/overcommit/hook/pre_push/brakeman.rb +13 -0
- data/lib/overcommit/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b67aff142df04c21f3edc1e45cb5e8e71b0f613
|
4
|
+
data.tar.gz: 148dede395ec550657a9d3b7c4bb9fa661784b7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9ec483cba901e73e9346682f6597f9d75dfc793bbabfc30a706cb04a633e2f33e20502d936478d34b834a53ea300402458adecee606d261dd55bf61838bc60f
|
7
|
+
data.tar.gz: 91ca7dd2c169bfc3ee5f464094d5decd186324bd765b7d7fd7a04f91a0335267eec065d7f21b1cf3756f64ff537d10c2dd26515d42dd9c027d77ef355ad8cf54
|
data/config/default.yml
CHANGED
@@ -247,6 +247,13 @@ PreCommit:
|
|
247
247
|
description: 'Check for file execute permissions'
|
248
248
|
quiet: true
|
249
249
|
|
250
|
+
Fasterer:
|
251
|
+
enabled: false
|
252
|
+
description: 'Analyzing for potential speed improvements'
|
253
|
+
required_executable: 'fasterer'
|
254
|
+
install_command: 'gem install fasterer'
|
255
|
+
include: '**/*.rb'
|
256
|
+
|
250
257
|
ForbiddenBranches:
|
251
258
|
enabled: false
|
252
259
|
description: 'Check for commit to forbidden branch'
|
@@ -549,6 +556,14 @@ PreCommit:
|
|
549
556
|
install_command: 'npm install -g standard'
|
550
557
|
include: '**/*.js'
|
551
558
|
|
559
|
+
TsLint:
|
560
|
+
enabled: false
|
561
|
+
description: 'Analyze with TSLint'
|
562
|
+
required_executable: 'tslint'
|
563
|
+
install_command: 'npm install -g tslint typescript'
|
564
|
+
flags: ['--t=prose']
|
565
|
+
include: '**/*.ts'
|
566
|
+
|
552
567
|
TrailingWhitespace:
|
553
568
|
enabled: false
|
554
569
|
description: 'Check for trailing whitespace'
|
@@ -855,6 +870,13 @@ PrePush:
|
|
855
870
|
description: 'Run Test::Unit test suite'
|
856
871
|
command: ['ruby', '-Ilib:test', '-rtest/unit', "-e 'exit! Test::Unit::AutoRunner.run'"]
|
857
872
|
|
873
|
+
Brakeman:
|
874
|
+
enabled: false
|
875
|
+
description: 'Check for security vulnerabilities'
|
876
|
+
required_executable: 'brakeman'
|
877
|
+
flags: ['--exit-on-warn', '--quiet', '--summary']
|
878
|
+
install_command: 'gem install brakeman'
|
879
|
+
|
858
880
|
# Hooks that run during `git rebase`, before any commits are rebased.
|
859
881
|
# If a hook fails, the rebase is aborted.
|
860
882
|
PreRebase:
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# rubocop:disable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/LineLength
|
1
2
|
module Overcommit
|
2
3
|
# Validates and normalizes a configuration.
|
3
4
|
class ConfigurationValidator
|
@@ -16,6 +17,7 @@ module Overcommit
|
|
16
17
|
hash = convert_nils_to_empty_hashes(hash)
|
17
18
|
ensure_hook_type_sections_exist(hash)
|
18
19
|
check_hook_name_format(hash)
|
20
|
+
check_hook_env(hash)
|
19
21
|
check_for_missing_enabled_option(hash) unless @options[:default]
|
20
22
|
check_for_too_many_processors(config, hash)
|
21
23
|
check_for_verify_plugin_signatures_option(hash)
|
@@ -51,6 +53,42 @@ module Overcommit
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
56
|
+
def check_hook_env(hash)
|
57
|
+
errors = []
|
58
|
+
|
59
|
+
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
|
+
|
63
|
+
unless hook_env.is_a?(Hash)
|
64
|
+
errors << "#{hook_type}::#{hook_name} has an invalid `env` specified: " \
|
65
|
+
'must be a hash of environment variable name to string value.'
|
66
|
+
next
|
67
|
+
end
|
68
|
+
|
69
|
+
hook_env.each do |var_name, var_value|
|
70
|
+
if var_name.include?('=')
|
71
|
+
errors << "#{hook_type}::#{hook_name} has an invalid `env` specified: " \
|
72
|
+
"variable name `#{var_name}` cannot contain `=`."
|
73
|
+
end
|
74
|
+
|
75
|
+
unless var_value.nil? || var_value.is_a?(String)
|
76
|
+
errors << "#{hook_type}::#{hook_name} has an invalid `env` specified: " \
|
77
|
+
"value of `#{var_name}` must be a string or `nil`, but was " \
|
78
|
+
"#{var_value.inspect} (#{var_value.class})"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if errors.any?
|
85
|
+
@log.error errors.join("\n") if @log
|
86
|
+
@log.newline if @log
|
87
|
+
raise Overcommit::Exceptions::ConfigurationError,
|
88
|
+
'One or more hooks had an invalid `env` configuration option'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
54
92
|
# Prints an error message and raises an exception if a hook has an
|
55
93
|
# invalid name, since this can result in strange errors elsewhere.
|
56
94
|
def check_hook_name_format(hash)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Overcommit::Hook::PreCommit
|
2
|
+
# Runs `fasterer` against any modified Ruby files.
|
3
|
+
#
|
4
|
+
# @see https://github.com/DamirSvrtan/fasterer
|
5
|
+
class Fasterer < Base
|
6
|
+
def run
|
7
|
+
result = execute(command, args: applicable_files)
|
8
|
+
output = result.stdout
|
9
|
+
|
10
|
+
if extract_offense_num(output) == 0
|
11
|
+
:pass
|
12
|
+
else
|
13
|
+
return [:warn, output]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def extract_offense_num(raw_output)
|
20
|
+
raw_output.scan(/(\d+) offense detected/).flatten.map(&:to_i).inject(0, :+)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Overcommit::Hook::PreCommit
|
2
|
+
# Runs `tslint` against modified TypeScript files.
|
3
|
+
# @see http://palantir.github.io/tslint/
|
4
|
+
class TsLint < Base
|
5
|
+
def run
|
6
|
+
result = execute(command, args: applicable_files)
|
7
|
+
output = result.stdout.chomp
|
8
|
+
return :pass if result.success? && output.empty?
|
9
|
+
|
10
|
+
# example message:
|
11
|
+
# src/file/anotherfile.ts[298, 1]: exceeds maximum line length of 140
|
12
|
+
extract_messages(
|
13
|
+
output.split("\n"),
|
14
|
+
/^(?<file>.+?(?=\[))[^\d]+(?<line>\d+).*?/
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Overcommit::Hook::PrePush
|
2
|
+
# Runs `brakeman` whenever Ruby/Rails files change.
|
3
|
+
#
|
4
|
+
# @see http://brakemanscanner.org/
|
5
|
+
class Brakeman < Base
|
6
|
+
def run
|
7
|
+
result = execute(command)
|
8
|
+
return :pass if result.success?
|
9
|
+
|
10
|
+
[:fail, result.stdout]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/overcommit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overcommit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.36.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brigade Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-08-
|
12
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: childprocess
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/overcommit/hook/pre_commit/dogma.rb
|
117
117
|
- lib/overcommit/hook/pre_commit/es_lint.rb
|
118
118
|
- lib/overcommit/hook/pre_commit/execute_permissions.rb
|
119
|
+
- lib/overcommit/hook/pre_commit/fasterer.rb
|
119
120
|
- lib/overcommit/hook/pre_commit/forbidden_branches.rb
|
120
121
|
- lib/overcommit/hook/pre_commit/go_lint.rb
|
121
122
|
- lib/overcommit/hook/pre_commit/go_vet.rb
|
@@ -156,6 +157,7 @@ files:
|
|
156
157
|
- lib/overcommit/hook/pre_commit/standard.rb
|
157
158
|
- lib/overcommit/hook/pre_commit/trailing_whitespace.rb
|
158
159
|
- lib/overcommit/hook/pre_commit/travis_lint.rb
|
160
|
+
- lib/overcommit/hook/pre_commit/ts_lint.rb
|
159
161
|
- lib/overcommit/hook/pre_commit/vint.rb
|
160
162
|
- lib/overcommit/hook/pre_commit/w3c_css.rb
|
161
163
|
- lib/overcommit/hook/pre_commit/w3c_html.rb
|
@@ -163,6 +165,7 @@ files:
|
|
163
165
|
- lib/overcommit/hook/pre_commit/xml_syntax.rb
|
164
166
|
- lib/overcommit/hook/pre_commit/yaml_syntax.rb
|
165
167
|
- lib/overcommit/hook/pre_push/base.rb
|
168
|
+
- lib/overcommit/hook/pre_push/brakeman.rb
|
166
169
|
- lib/overcommit/hook/pre_push/minitest.rb
|
167
170
|
- lib/overcommit/hook/pre_push/protected_branches.rb
|
168
171
|
- lib/overcommit/hook/pre_push/r_spec.rb
|