Skip to content

Commit 3c37254

Browse files
committed
Update RuboCop 0.49.1 -> 0.52.1 for CI
While here, we had to update the minimum Ruby version from 2.0 to 2.1 since RuboCop no longer supports Ruby 2.0. Ruby 2.0 has been marked EOL since February 2016, so it seems reasonable to disable support for it. While here, we had to fix a lot of RuboCop warnings.
1 parent 0a0c9e4 commit 3c37254

29 files changed

+80
-91
lines changed

.rubocop.yml

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
AllCops:
2+
TargetRubyVersion: 2.1
3+
14
Layout/ClosingParenthesisIndentation:
25
Enabled: false
36

@@ -54,6 +57,22 @@ Metrics/MethodLength:
5457
Metrics/ModuleLength:
5558
Enabled: false
5659

60+
Naming/FileName:
61+
Exclude:
62+
- 'template-dir/hooks/*'
63+
- 'Gemfile'
64+
- 'Rakefile'
65+
- '*.gemspec'
66+
67+
# Renaming `has_something?` to `something?` obfuscates whether it is a "is-a" or
68+
# a "has-a" relationship.
69+
Naming/PredicateName:
70+
Enabled: false
71+
72+
# commit_sha1 is indeed how we want to write such a variable, so ignore this cop
73+
Naming/VariableNumber:
74+
Enabled: false
75+
5776
# Enforcing this results in a lot of unnecessary indentation.
5877
Style/ClassAndModuleChildren:
5978
Enabled: false
@@ -62,16 +81,6 @@ Style/Documentation:
6281
Exclude:
6382
- 'spec/overcommit/**/*'
6483

65-
Style/Encoding:
66-
EnforcedStyle: when_needed
67-
68-
Style/FileName:
69-
Exclude:
70-
- 'template-dir/hooks/*'
71-
- 'Gemfile'
72-
- 'Rakefile'
73-
- '*.gemspec'
74-
7584
Style/FormatString:
7685
Enabled: false
7786

@@ -112,11 +121,6 @@ Style/PercentLiteralDelimiters:
112121
'%W': '[]'
113122
'%x': '{}'
114123

115-
# Renaming `has_something?` to `something?` obfuscates whether it is a "is-a" or
116-
# a "has-a" relationship.
117-
Style/PredicateName:
118-
Enabled: false
119-
120124
Style/RescueModifier:
121125
Exclude:
122126
- 'bin/overcommit'
@@ -140,7 +144,3 @@ Style/TrailingCommaInArguments:
140144

141145
Style/TrailingCommaInLiteral:
142146
Enabled: false
143-
144-
# commit_sha1 is indeed how we want to write such a variable, so ignore this cop
145-
Style/VariableNumber:
146-
Enabled: false

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ gem 'rspec', '~> 3.0'
1010
gem 'coveralls', '~> 0.8'
1111

1212
# Pin RuboCop for Travis builds.
13-
gem 'rubocop', '0.49.1'
13+
gem 'rubocop', '0.52.1'

lib/overcommit/configuration_loader.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def load_file(file)
7272
config
7373
rescue Overcommit::Exceptions::ConfigurationSignatureChanged
7474
raise
75-
rescue => error
75+
rescue StandardError => error
7676
raise Overcommit::Exceptions::ConfigurationError,
7777
"Unable to load configuration from '#{file}': #{error}",
7878
error.backtrace

lib/overcommit/configuration_validator.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def check_hook_name_format(hash)
9595
errors = []
9696

9797
Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
98-
hash.fetch(hook_type, {}).each do |hook_name, _|
98+
hash.fetch(hook_type, {}).each_key do |hook_name|
9999
next if hook_name == 'ALL'
100100

101101
unless hook_name =~ /\A[A-Za-z0-9]+\z/
@@ -175,3 +175,4 @@ def check_for_verify_plugin_signatures_option(hash)
175175
end
176176
end
177177
end
178+
# rubocop:enable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/LineLength

lib/overcommit/hook_runner.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def run_hook(hook) # rubocop:disable Metrics/CyclomaticComplexity
156156
rescue Overcommit::Exceptions::MessageProcessingError => ex
157157
status = :fail
158158
output = ex.message
159-
rescue => ex
159+
rescue StandardError => ex
160160
status = :fail
161161
output = "Hook raised unexpected error\n#{ex.message}\n#{ex.backtrace.join("\n")}"
162162
end

lib/overcommit/printer.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
require 'monitor'
42

53
module Overcommit

lib/overcommit/subprocess.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def spawn(args, options = {})
3636
if options[:input]
3737
begin
3838
process.io.stdin.puts(options[:input])
39-
rescue # rubocop:disable Lint/HandleExceptions
39+
rescue StandardError # rubocop:disable Lint/HandleExceptions
4040
# Silently ignore if the standard input stream of the spawned
4141
# process is closed before we get a chance to write to it. This
4242
# happens on JRuby a lot.

overcommit.gemspec

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative './lib/overcommit/constants'
24
require_relative './lib/overcommit/version'
35

@@ -23,7 +25,7 @@ Gem::Specification.new do |s|
2325
Dir['libexec/**/*'] +
2426
Dir['template-dir/**/*']
2527

26-
s.required_ruby_version = '>= 2'
28+
s.required_ruby_version = '>= 2.1'
2729

2830
s.add_dependency 'childprocess', '~> 0.6', '>= 0.6.3'
2931
s.add_dependency 'iniparse', '~> 1.4'

spec/overcommit/hook/commit_msg/capitalized_subject_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
require 'spec_helper'
42

53
describe Overcommit::Hook::CommitMsg::CapitalizedSubject do

spec/overcommit/hook/commit_msg/spell_check_spec.rb

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
require 'spec_helper'
42

53
describe Overcommit::Hook::CommitMsg::SpellCheck do
@@ -21,12 +19,12 @@
2119

2220
context 'with no misspellings' do
2321
before do
24-
result.stub(:stdout).and_return(<<-EOS)
22+
result.stub(:stdout).and_return(<<-MSG)
2523
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.3)
2624
*
2725
*
2826
*
29-
EOS
27+
MSG
3028
end
3129

3230
it { should pass }
@@ -35,25 +33,25 @@
3533
context 'with misspellings' do
3634
context 'with suggestions' do
3735
before do
38-
result.stub(:stdout).and_return(<<-EOS)
36+
result.stub(:stdout).and_return(<<-MSG)
3937
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.3)
4038
*
4139
& msg 10 4: MSG, mag, ms, mg, meg, mtg, mug, mpg, mfg, ms g
4240
*
43-
EOS
41+
MSG
4442
end
4543

4644
it { should warn(/^Potential misspelling: \w+. Suggestions: .+$/) }
4745
end
4846

4947
context 'with no suggestions' do
5048
before do
51-
result.stub(:stdout).and_return(<<-EOS)
49+
result.stub(:stdout).and_return(<<-MSG)
5250
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.3)
5351
*
5452
# supercalifragilisticexpialidocious 4
5553
*
56-
EOS
54+
MSG
5755
end
5856

5957
it { should warn(/^Potential misspelling: \w+.$/) }
@@ -65,9 +63,9 @@
6563
let(:result) { double('result') }
6664

6765
before do
68-
result.stub(success?: false, stderr: <<-EOS)
66+
result.stub(success?: false, stderr: <<-MSG)
6967
Can't open affix or dictionary files for dictionary named "foo".
70-
EOS
68+
MSG
7169
end
7270

7371
it { should fail_hook }

spec/overcommit/hook/pre_commit/bundle_audit_spec.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,23 @@
3636
let(:result) do
3737
double(
3838
success?: false,
39-
stdout: <<-EOF
39+
stdout: <<-MSG
4040
Name: rest-client
4141
Version: 1.6.9
4242
Advisory: CVE-2015-1820
4343
Criticality: Unknown
4444
URL: https://github.com/rest-client/rest-client/issues/369
4545
Title: rubygem-rest-client: session fixation vulnerability via Set-Cookie headers in 30x redirection responses
4646
Solution: upgrade to >= 1.8.0
47-
4847
Name: rest-client
4948
Version: 1.6.9
5049
Advisory: CVE-2015-3448
5150
Criticality: Unknown
5251
URL: http://www.osvdb.org/show/osvdb/117461
5352
Title: Rest-Client Gem for Ruby logs password information in plaintext
5453
Solution: upgrade to >= 1.7.3
55-
5654
Vulnerabilities found!
57-
EOF
55+
MSG
5856
)
5957
end
6058

@@ -64,10 +62,10 @@
6462
let(:result) do
6563
double(
6664
success?: false,
67-
stdout: <<-EOF
65+
stdout: <<-MSG
6866
Insecure Source URI found: git://github.com/xxx/overcommit.git
6967
Vulnerabilities found!
70-
EOF
68+
MSG
7169
)
7270
end
7371

spec/overcommit/hook/pre_commit/bundle_outdated_spec.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535

3636
context 'and it reports some outdated gems' do
3737
let(:result) do
38-
double(stdout: <<-EOF
38+
double(stdout: <<-MSG
3939
Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
40-
4140
airbrake (newest 5.3.0, installed 5.2.3, requested ~> 5.0)
4241
aws-sdk (newest 2.3.3, installed 2.3.1, requested ~> 2)
4342
font-awesome-rails (newest 4.6.2.0, installed 4.6.1.0)
@@ -48,7 +47,7 @@
4847
aws-sdk-resources (newest 2.3.3, installed 2.3.1)
4948
config (newest 1.1.1, installed 1.1.0)
5049
ruby_parser (newest 3.8.2, installed 3.8.1)
51-
EOF
50+
MSG
5251
)
5352
end
5453

@@ -57,10 +56,9 @@
5756

5857
context 'and it reports bundle up to date' do
5958
let(:result) do
60-
double(stdout: <<-EOF
59+
double(stdout: <<-MSG
6160
Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
62-
63-
EOF
61+
MSG
6462
)
6563
end
6664

spec/overcommit/hook/pre_commit/fasterer_spec.rb

+4-8
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,17 @@
2424
let(:result) do
2525
double(
2626
success?: false,
27-
stdout: <<-EOF
27+
stdout: <<-MSG
2828
spec/models/product_spec.rb
2929
Using each_with_index is slower than while loop. Occurred at lines: 52.
30-
3130
1 files inspected, 1 offense detected
3231
spec/models/book_spec.rb
3332
Using each_with_index is slower than while loop. Occurred at lines: 32.
34-
3533
1 files inspected, 1 offense detected
3634
spec/models/blog_spec.rb
3735
Using each_with_index is slower than while loop. Occurred at lines: 12.
38-
3936
2 files inspected, 0 offense detected
40-
EOF
37+
MSG
4138
)
4239
end
4340

@@ -48,12 +45,11 @@
4845
let(:result) do
4946
double(
5047
success?: false,
51-
stdout: <<-EOF
48+
stdout: <<-MSG
5249
spec/models/product_spec.rb
5350
Using each_with_index is slower than while loop. Occurred at lines: 52.
54-
5551
1 files inspected, 1 offense detected
56-
EOF
52+
MSG
5753
)
5854
end
5955

spec/overcommit/hook/pre_commit/foodcritic_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
double(
4343
success?: false,
4444
stderr: '',
45-
stdout: <<-EOF,
45+
stdout: <<-MSG,
4646
FC023: Prefer conditional attributes: recipes/default.rb:11
4747
FC065: Ensure source_url is set in metadata: metadata.rb:1
48-
EOF
48+
MSG
4949
)
5050
end
5151

@@ -104,10 +104,10 @@
104104
double(
105105
success?: false,
106106
stderr: '',
107-
stdout: <<-EOF,
107+
stdout: <<-MSG,
108108
FC023: Prefer conditional attributes: cookbooks/cookbook_a/recipes/default.rb:11
109109
FC065: Ensure source_url is set in metadata: cookbooks/cookbook_b/metadata.rb:1
110-
EOF
110+
MSG
111111
)
112112
end
113113

spec/overcommit/hook/pre_commit/hadolint_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727
let(:result_dockerfile) do
2828
double(
2929
success?: false,
30-
stdout: <<-EOF
30+
stdout: <<-MSG
3131
Dockerfile:5 DL3015 Avoid additional packages by specifying `--no-install-recommends`
32-
EOF
32+
MSG
3333
)
3434
end
3535
let(:result_dockerfile_web) do
3636
double(
3737
success?: false,
38-
stdout: <<-EOF
38+
stdout: <<-MSG
3939
Dockerfile.web:13 DL3020 Use COPY instead of ADD for files and folders
40-
EOF
40+
MSG
4141
)
4242
end
4343

@@ -48,9 +48,9 @@
4848
let(:result_dockerfile) do
4949
double(
5050
success?: false,
51-
stdout: <<-EOF
51+
stdout: <<-MSG
5252
Dockerfile:11 SC2086 Double quote to prevent globbing and word splitting.
53-
EOF
53+
MSG
5454
)
5555
end
5656
let(:result_dockerfile_web) do

0 commit comments

Comments
 (0)