Skip to content

Commit 942969a

Browse files
committed
Update RuboCop used in CI from 0.54.0 to 0.82.0
While here, run an auto-correct. Note: RuboCop 1.0 has been released, but as we haven't seen any fundamental bug reports yet, it seems safe to only upgrade to 0.82.0 at this time, largely due to the new `--disable-pending-cops` flag introduced in this version.
1 parent 919350b commit 942969a

File tree

105 files changed

+382
-352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+382
-352
lines changed

.rubocop.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ Layout/EndOfLine:
1414
Layout/FirstParameterIndentation:
1515
Enabled: false
1616

17-
Layout/IndentArray:
17+
Layout/FirstArrayElementIndentation:
1818
Enabled: false
1919

20-
Layout/IndentHeredoc:
20+
Layout/HeredocIndentation:
2121
Enabled: false
2222

23+
Layout/LineLength:
24+
Max: 100
25+
2326
Layout/MultilineMethodCallIndentation:
2427
Enabled: false
2528

@@ -48,9 +51,6 @@ Metrics/AbcSize:
4851
Metrics/BlockLength:
4952
Enabled: false
5053

51-
Metrics/LineLength:
52-
Max: 100
53-
5454
Metrics/MethodLength:
5555
Max: 20
5656

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## master (unreleased)
44

5-
* Add `--disable-pending-cops` as default flag to `RuboCop` pre-commit hook to ignore non-existent cops.
5+
* Add `--disable-pending-cops` as default flag to `RuboCop` pre-commit hook to ignore non-existent cops. Requires RuboCop `0.82.0` or newer.
66

77
## 0.58.0
88

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ gem 'rspec', '~> 3.0'
1212
gem 'coveralls', '~> 0.8'
1313

1414
# Pin RuboCop for Travis builds.
15-
gem 'rubocop', '0.54.0'
15+
gem 'rubocop', '0.82.0'
1616

1717
gem 'ffi' if Gem.win_platform?

bin/overcommit

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
1818
ensure
1919
$stderr = old_stderr
2020
end
21-
rescue Bundler::BundlerError => ex
22-
puts "Problem loading '#{gemfile}': #{ex.message}"
23-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
21+
rescue Bundler::BundlerError => e
22+
puts "Problem loading '#{gemfile}': #{e.message}"
23+
puts "Try running:\nbundle install --gemfile=#{gemfile}" if e.is_a?(Bundler::GemNotFound)
2424
exit 78 # EX_CONFIG
25-
rescue Gem::LoadError => ex
25+
rescue Gem::LoadError => e
2626
# Handle case where user is executing overcommit without `bundle exec` and
2727
# whose local Gemfile has a gem requirement that does not match a gem
2828
# requirement of the installed version of Overcommit.
29-
raise unless ex.message =~ /already activated/i
29+
raise unless e.message =~ /already activated/i
30+
3031
exec('bundle', 'exec', $0, *ARGV)
3132
end
3233
end

lib/overcommit/cli.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
module Overcommit
77
# Responsible for parsing command-line options and executing appropriate
88
# application logic based on those options.
9-
class CLI # rubocop:disable ClassLength
9+
class CLI # rubocop:disable Metrics/ClassLength
1010
def initialize(arguments, input, logger)
1111
@arguments = arguments
1212
@input = input
@@ -29,11 +29,11 @@ def run
2929
when :run_all
3030
run_all
3131
end
32-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => ex
33-
puts ex
32+
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => e
33+
puts e
3434
exit 78 # EX_CONFIG
35-
rescue Overcommit::Exceptions::HookContextLoadError => ex
36-
puts ex
35+
rescue Overcommit::Exceptions::HookContextLoadError => e
36+
puts e
3737
exit 64 # EX_USAGE
3838
end
3939

@@ -52,8 +52,8 @@ def parse_arguments
5252

5353
# Unconsumed arguments are our targets
5454
@options[:targets] = @arguments
55-
rescue OptionParser::InvalidOption => ex
56-
print_help @parser.help, ex
55+
rescue OptionParser::InvalidOption => e
56+
print_help @parser.help, e
5757
end
5858
end
5959

@@ -125,11 +125,11 @@ def install_or_uninstall
125125
@options[:targets].each do |target|
126126
begin
127127
Installer.new(log).run(target, @options)
128-
rescue Overcommit::Exceptions::InvalidGitRepo => error
129-
log.warning "Invalid repo #{target}: #{error}"
128+
rescue Overcommit::Exceptions::InvalidGitRepo => e
129+
log.warning "Invalid repo #{target}: #{e}"
130130
halt 69 # EX_UNAVAILABLE
131-
rescue Overcommit::Exceptions::PreExistingHooks => error
132-
log.warning "Unable to install into #{target}: #{error}"
131+
rescue Overcommit::Exceptions::PreExistingHooks => e
132+
log.warning "Unable to install into #{target}: #{e}"
133133
halt 73 # EX_CANTCREAT
134134
end
135135
end

lib/overcommit/command_splitter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ def arguments_under_limit(splittable_args, start_index, byte_limit)
107107

108108
loop do
109109
break if index > splittable_args.length - 1
110+
110111
total_bytes += splittable_args[index].bytesize
111112
break if total_bytes > byte_limit # Not enough room
113+
112114
index += 1
113115
end
114116

lib/overcommit/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module Overcommit
77
# Stores configuration for Overcommit and the hooks it runs.
8-
class Configuration # rubocop:disable ClassLength
8+
class Configuration # rubocop:disable Metrics/ClassLength
99
# Creates a configuration from the given hash.
1010
#
1111
# @param hash [Hash] loaded YAML config file as a hash

lib/overcommit/configuration_loader.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ def load_file(file)
7575
config
7676
rescue Overcommit::Exceptions::ConfigurationSignatureChanged
7777
raise
78-
rescue StandardError => error
78+
rescue StandardError => e
7979
raise Overcommit::Exceptions::ConfigurationError,
80-
"Unable to load configuration from '#{file}': #{error}",
81-
error.backtrace
80+
"Unable to load configuration from '#{file}': #{e}",
81+
e.backtrace
8282
end
8383

8484
private

lib/overcommit/git_config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def comment_character
1616
def hooks_path
1717
path = `git config --get core.hooksPath`.chomp
1818
return File.join(Overcommit::Utils.git_dir, 'hooks') if path.empty?
19+
1920
File.absolute_path(path, Dir.pwd)
2021
end
2122
end

lib/overcommit/git_repo.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ module GitRepo
1414
[^\s]+\s # Ignore old file range
1515
\+(\d+)(?:,(\d+))? # Extract range of hunk containing start line and number of lines
1616
\s@@.*$
17-
/x
17+
/x.freeze
1818

1919
# Regular expression used to extract information from lines of
2020
# `git submodule status` output
2121
SUBMODULE_STATUS_REGEX = /
2222
^\s*(?<prefix>[-+U]?)(?<sha1>\w+)
2323
\s(?<path>[^\s]+?)
2424
(?:\s\((?<describe>.+)\))?$
25-
/x
25+
/x.freeze
2626

2727
# Struct encapsulating submodule information extracted from the
2828
# output of `git submodule status`
@@ -262,9 +262,9 @@ def submodules(options = {})
262262
end
263263

264264
modules
265-
rescue IniParse::IniParseError => ex
265+
rescue IniParse::IniParseError => e
266266
raise Overcommit::Exceptions::GitSubmoduleError,
267-
"Unable to read submodule information from #{ref}:.gitmodules file: #{ex.message}"
267+
"Unable to read submodule information from #{ref}:.gitmodules file: #{e.message}"
268268
end
269269

270270
# Returns the names of all branches containing the given commit.

0 commit comments

Comments
 (0)