Skip to content

Commit 9893350

Browse files
committed
Upgrade RuboCop 0.35.1 -> 0.36.0 for Travis builds
This required a number of fixes to address new cops introduced in version 0.36.0.
1 parent 37a62b4 commit 9893350

19 files changed

+53
-40
lines changed

.rubocop.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Style/FormatString:
5454
Style/GuardClause:
5555
Enabled: false
5656

57+
Style/IndentArray:
58+
Enabled: false
59+
5760
Style/IfUnlessModifier:
5861
Enabled: false
5962

@@ -63,6 +66,9 @@ Style/IfUnlessModifier:
6366
Style/Lambda:
6467
Enabled: false
6568

69+
Style/MultilineMethodCallIndentation:
70+
Enabled: false
71+
6672
Style/MultilineOperationIndentation:
6773
Enabled: false
6874

@@ -98,12 +104,15 @@ Style/SignalException:
98104
Style/SingleLineBlockParams:
99105
Enabled: false
100106

101-
Style/SingleSpaceBeforeFirstArg:
107+
Style/SpaceBeforeFirstArg:
102108
Exclude:
103109
- '*.gemspec'
104110

105111
Style/SpecialGlobalVars:
106112
Enabled: false
107113

108-
Style/TrailingComma:
114+
Style/TrailingCommaInArguments:
115+
Enabled: false
116+
117+
Style/TrailingCommaInLiteral:
109118
Enabled: false

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ source 'https://rubygems.org'
44
gem 'coveralls'
55

66
# Pin RuboCop for Travis builds.
7-
gem 'rubocop', '0.35.1'
7+
gem 'rubocop', '0.36.0'
88

99
gemspec

lib/overcommit/configuration.rb

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def initialize(hash, options = {})
1919
def ==(other)
2020
super || @hash == other.hash
2121
end
22-
alias_method :eql?, :==
2322

2423
# Access the configuration as if it were a hash.
2524
#

lib/overcommit/constants.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Global application constants.
22
module Overcommit
3-
HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
4-
CONFIG_FILE_NAME = '.overcommit.yml'
3+
HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
4+
CONFIG_FILE_NAME = '.overcommit.yml'.freeze
55

6-
HOOK_DIRECTORY = File.join(HOME, 'lib', 'overcommit', 'hook')
6+
HOOK_DIRECTORY = File.join(HOME, 'lib', 'overcommit', 'hook').freeze
77

8-
REPO_URL = 'https://github.com/brigade/overcommit'
9-
BUG_REPORT_URL = "#{REPO_URL}/issues"
8+
REPO_URL = 'https://github.com/brigade/overcommit'.freeze
9+
BUG_REPORT_URL = "#{REPO_URL}/issues".freeze
1010
end

lib/overcommit/hook/base.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def to_s
1111
end
1212

1313
# Possible types of messages.
14-
MESSAGE_TYPES = [:error, :warning]
14+
MESSAGE_TYPES = [:error, :warning].freeze
1515

1616
# Functionality common to all hooks.
1717
class Base # rubocop:disable Metrics/ClassLength

lib/overcommit/hook/commit_msg/capitalized_subject.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def run
55
return :pass if empty_message?
66

77
first_letter = commit_message_lines[0].to_s.match(/^[[:punct:]]*(.)/)[1]
8-
unless first_letter.match(/[[:upper:]]/)
8+
unless first_letter =~ /[[:upper:]]/
99
return :warn, 'Subject should start with a capital letter'
1010
end
1111

lib/overcommit/hook/pre_commit/berksfile_check.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Overcommit::Hook::PreCommit
44
#
55
# @see http://berkshelf.com/
66
class BerksfileCheck < Base
7-
LOCK_FILE = 'Berksfile.lock'
7+
LOCK_FILE = 'Berksfile.lock'.freeze
88

99
def run
1010
# Ignore if Berksfile.lock is not tracked by git

lib/overcommit/hook/pre_commit/bundle_check.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Overcommit::Hook::PreCommit
44
#
55
# @see http://bundler.io/
66
class BundleCheck < Base
7-
LOCK_FILE = 'Gemfile.lock'
7+
LOCK_FILE = 'Gemfile.lock'.freeze
88

99
def run
1010
# Ignore if Gemfile.lock is not tracked by git

lib/overcommit/hook_signer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class HookSigner
55

66
# We don't want to include the skip setting as it is set by Overcommit
77
# itself
8-
IGNORED_CONFIG_KEYS = %w[skip]
8+
IGNORED_CONFIG_KEYS = %w[skip].freeze
99

1010
# @param hook_name [String] name of the hook
1111
# @param config [Overcommit::Configuration]

lib/overcommit/message_processor.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ module Overcommit
66
# output tuple from an array of {Overcommit::Hook::Message}s, respecting the
77
# configuration settings for the given hook.
88
class MessageProcessor
9-
ERRORS_MODIFIED_HEADER = 'Errors on modified lines:'
10-
WARNINGS_MODIFIED_HEADER = 'Warnings on modified lines:'
11-
ERRORS_UNMODIFIED_HEADER = "Errors on lines you didn't modify:"
12-
WARNINGS_UNMODIFIED_HEADER = "Warnings on lines you didn't modify:"
9+
ERRORS_MODIFIED_HEADER = 'Errors on modified lines:'.freeze
10+
WARNINGS_MODIFIED_HEADER = 'Warnings on modified lines:'.freeze
11+
ERRORS_UNMODIFIED_HEADER = "Errors on lines you didn't modify:".freeze
12+
WARNINGS_UNMODIFIED_HEADER = "Warnings on lines you didn't modify:".freeze
1313

1414
# @param hook [Overcommit::Hook::Base]
1515
# @param unmodified_lines_setting [String] how to treat messages on

lib/overcommit/os.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def linux?
2727
private
2828

2929
def host_os
30-
@os ||= ::RbConfig::CONFIG['host_os']
30+
@os ||= ::RbConfig::CONFIG['host_os'].freeze
3131
end
3232
end
3333

34-
SEPARATOR = self.windows? ? '\\' : File::SEPARATOR
34+
SEPARATOR = (windows? ? '\\' : File::SEPARATOR).freeze
3535
end
3636
end

lib/overcommit/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Defines the gem version.
22
module Overcommit
3-
VERSION = '0.30.0'
3+
VERSION = '0.30.0'.freeze
44
end

spec/overcommit/command_splitter_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
end
7676

7777
context 'with splittable arguments well over the limit' do
78-
let(:splittable_args) { 15.times.map { |i| (i + 1).to_s } }
78+
let(:splittable_args) { Array.new(15) { |i| (i + 1).to_s } }
7979

8080
it 'executes multiple commands with the appropriately split arguments' do
8181
Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 1 2 3 4 5 6 7],

spec/overcommit/hook/pre_commit/scalastyle_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888

8989
context 'with a runtime error' do
9090
before do
91-
# rubocop:disable Metrics/LineLength
9291
result.stub(stdout: '', stderr: normalize_indent(<<-ERR))
9392
Exception in thread "main" java.io.FileNotFoundException: scalastyle-config.xml (No such file or directory)
9493
at java.io.FileInputStream.open0(Native Method)
@@ -103,7 +102,6 @@
103102
at org.scalastyle.Main$.main(Main.scala:95)
104103
at org.scalastyle.Main.main(Main.scala)
105104
ERR
106-
# rubocop:enable Metrics/LineLength
107105
end
108106

109107
it { should fail_hook }

spec/overcommit/hook/pre_push/r_spec_spec.rb

-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
context 'with a runtime error' do
2828
before do
29-
# rubocop:disable Metrics/LineLength
3029
result.stub(stdout: '', stderr: <<-EOS)
3130
/home/user/.rbenv/gems/2.2.0/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226:in `load': /home/user/dev/github/overcommit/spec/overcommit/hook/pre_push/rspec_spec.rb:49: can't find string "EOS" anywhere before EOF (SyntaxError)
3231
/home/user/dev/overcommit/spec/overcommit/hook/pre_push/rspec_spec.rb:29: syntax error, unexpected end-of-input
@@ -41,15 +40,13 @@
4140
from /home/user/.rbenv/versions/2.2.1/bin/rspec:23:in `load'
4241
from /home/user/.rbenv/versions/2.2.1/bin/rspec:23:in `<main>'
4342
EOS
44-
# rubocop:enable Metrics/LineLength
4543
end
4644

4745
it { should fail_hook }
4846
end
4947

5048
context 'with a test failure' do
5149
before do
52-
# rubocop:disable Metrics/LineLength
5350
result.stub(stderr: '', stdout: <<-EOS)
5451
.FF
5552
@@ -73,7 +70,6 @@
7370
rspec ./spec/overcommit/hook/pre_push/rspec_spec.rb:45 # Overcommit::Hook::PrePush::RSpec when rspec exits unsuccessfully with a runtime error should fail
7471
rspec ./spec/overcommit/hook/pre_push/rspec_spec.rb:57 # Overcommit::Hook::PrePush::RSpec when rspec exits unsuccessfully with a test failure should fail
7572
EOS
76-
# rubocop:enable Metrics/LineLength
7773
end
7874

7975
it { should fail_hook }

spec/overcommit/utils_spec.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@
192192
subject { described_class.execute(arguments, args: splittable_args) }
193193

194194
it 'invokes CommandSplitter.execute' do
195-
Overcommit::CommandSplitter.should_receive(:execute).
196-
with(arguments, args: splittable_args).
197-
and_return(double(status: 0, stdout: '', stderr: ''))
195+
Overcommit::CommandSplitter.
196+
should_receive(:execute).
197+
with(arguments, args: splittable_args).
198+
and_return(double(status: 0, stdout: '', stderr: ''))
198199
subject
199200
end
200201

spec/spec_helper.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
require 'overcommit'
1212
require 'tempfile'
1313

14-
hook_types = Dir[File.join(Overcommit::HOOK_DIRECTORY, '*')].
14+
hook_types =
15+
Dir[File.join(Overcommit::HOOK_DIRECTORY, '*')].
1516
select { |f| File.directory?(f) }.
1617
reject { |f| File.basename(f) == 'shared' }.
1718
sort

spec/support/git_spec_helpers.rb

+15-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
module GitSpecHelpers
55
module_function
66

7-
def repo(options = {}, &block)
7+
# Creates an empty git repository, allowing you to execute a block where
8+
# the current working directory is set to that repository's root directory.
9+
#
10+
# @param options [Hash]
11+
# @return [String] path of the repository
12+
def repo(options = {})
813
directory('some-repo') do
914
`git init --template="#{options[:template_dir]}"`
1015

@@ -13,26 +18,30 @@ def repo(options = {}, &block)
1318
`git config --local user.email "overcommit@example.com"`
1419
`git config --local rerere.enabled 0` # Don't record resolutions in tests
1520

16-
block.call if block_given?
21+
yield if block_given?
1722
end
1823
end
1924

2025
# Creates a directory (with an optional specific name) in a temporary
2126
# directory which will automatically be destroyed.
27+
#
28+
# @param name [String] base name of the directory
29+
# @return [String] path of the directory that was created
2230
def directory(name = 'some-dir', &block)
2331
tmpdir = Dir.mktmpdir.tap do |path|
2432
Dir.chdir(path) do
2533
Dir.mkdir(name)
26-
Dir.chdir(name) do
27-
block.call if block_given?
28-
end
34+
Dir.chdir(name, &block) if block_given?
2935
end
3036
end
3137

3238
File.join(tmpdir, name)
3339
end
3440

41+
# Returns a random git object hash.
42+
#
43+
# @return [String]
3544
def random_hash
36-
40.times.map { (65 + rand(26)).chr }.join
45+
Array.new(40) { (65 + rand(26)).chr }.join
3746
end
3847
end

spec/support/shell_helpers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def touch(file)
2020
#
2121
# @param options [Hash]
2222
# @raise [Timeout::TimeoutError] timeout has elapsed before condition holds
23-
def wait_until(options = {}, &block)
23+
def wait_until(options = {})
2424
Timeout.timeout(options.fetch(:timeout, 1)) do
2525
loop do
26-
return if block.call
26+
return if yield
2727
sleep options.fetch(:check_interval, 0.1)
2828
end
2929
end

0 commit comments

Comments
 (0)