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

+5-5
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

+1-1
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

+1-1
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

+6-5
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

+11-11
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

+2
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

+1-1
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

+3-3
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

+1
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

+4-4
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.

lib/overcommit/hook/commit_msg/spell_check.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Overcommit::Hook::CommitMsg
99
class SpellCheck < Base
1010
Misspelling = Struct.new(:word, :suggestions)
1111

12-
MISSPELLING_REGEX = /^[&#]\s(?<word>\w+)(?:.+?:\s(?<suggestions>.*))?/
12+
MISSPELLING_REGEX = /^[&#]\s(?<word>\w+)(?:.+?:\s(?<suggestions>.*))?/.freeze
1313

1414
def run
1515
result = execute(command + [uncommented_commit_msg_file])

lib/overcommit/hook/commit_msg/text_width.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def find_errors_in_subject(subject)
3232
min_subject_width = config['min_subject_width']
3333
if subject.length < min_subject_width
3434
@errors << "Commit message subject must be >= #{min_subject_width} characters"
35-
return
35+
nil
3636
end
3737
end
3838

lib/overcommit/hook/post_checkout/base.rb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def skip_file_checkout?
1616

1717
def enabled?
1818
return false if file_checkout? && skip_file_checkout?
19+
1920
super
2021
end
2122
end

lib/overcommit/hook/post_commit/git_guilt.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ module Overcommit::Hook::PostCommit
55
#
66
# @see https://www.npmjs.com/package/git-guilt
77
class GitGuilt < Base
8-
PLUS_MINUS_REGEX = /^(.*?)(?:(\++)|(-+))$/
8+
PLUS_MINUS_REGEX = /^(.*?)(?:(\++)|(-+))$/.freeze
99
GREEN = 32
1010
RED = 31
1111

1212
def run
1313
return :pass if initial_commit?
14+
1415
result = execute(command)
1516
return :fail, result.stderr unless result.success?
1617

lib/overcommit/hook/pre_commit/bundle_audit.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def run
1717
if result.success?
1818
:pass
1919
else
20-
return [:warn, result.stdout]
20+
[:warn, result.stdout]
2121
end
2222
end
2323
end

lib/overcommit/hook/pre_commit/chamber_compare.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def run
1414
next unless second
1515

1616
result = execute(
17-
command,
18-
args: [
19-
"--first=#{first.join(' ')}",
20-
"--second=#{second.join(' ')}",
21-
],
17+
command,
18+
args: [
19+
"--first=#{first.join(' ')}",
20+
"--second=#{second.join(' ')}",
21+
],
2222
)
2323

2424
unless result.stdout.empty?

lib/overcommit/hook/pre_commit/chamber_security.rb

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def run
99
result = execute(command, args: applicable_files)
1010

1111
return :pass if result.stdout.empty?
12+
1213
[:fail, "These settings appear to need to be secured but were not: #{result.stdout}"]
1314
end
1415
end

lib/overcommit/hook/pre_commit/coffee_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CoffeeLint < Base
1010
,(?<line>\d*),\d*
1111
,(?<type>\w+)
1212
,(?<msg>.+)$
13-
/x
13+
/x.freeze
1414

1515
MESSAGE_TYPE_CATEGORIZER = lambda do |type|
1616
type.include?('w') ? :warning : :error

lib/overcommit/hook/pre_commit/css_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CssLint < Base
99
^(?<file>(?:\w:)?[^:]+):\s
1010
(?:line\s(?<line>\d+)[^EW]+)?
1111
(?<type>Error|Warning)
12-
/x
12+
/x.freeze
1313

1414
def run
1515
result = execute(command, args: applicable_files)

lib/overcommit/hook/pre_commit/dart_analyzer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Overcommit::Hook::PreCommit
44
# Runs `dartanalyzer` against modified Dart files.
55
# @see https://dart.dev/tools/dartanalyzer
66
class DartAnalyzer < Base
7-
MESSAGE_REGEX = /(?<type>.*)•\ (?<message>[^•]+)•\ (?<file>[^:]+):(?<line>\d+):(\d+)\.*/
7+
MESSAGE_REGEX = /(?<type>.*)•\ (?<message>[^•]+)•\ (?<file>[^:]+):(?<line>\d+):(\d+)\.*/.freeze
88

99
def run
1010
result = execute(command, args: applicable_files)

lib/overcommit/hook/pre_commit/erb_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Overcommit::Hook::PreCommit
55
#
66
# @see https://github.com/Shopify/erb-lint
77
class ErbLint < Base
8-
MESSAGE_REGEX = /(?<message>.+)\nIn file: (?<file>.+):(?<line>\d+)/
8+
MESSAGE_REGEX = /(?<message>.+)\nIn file: (?<file>.+):(?<line>\d+)/.freeze
99

1010
def run
1111
result = execute(command, args: applicable_files)

lib/overcommit/hook/pre_commit/fasterer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def run
1212
if extract_offense_num(output) == 0
1313
:pass
1414
else
15-
return [:warn, output]
15+
[:warn, output]
1616
end
1717
end
1818

lib/overcommit/hook/pre_commit/foodcritic.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def run
102102
if result.success?
103103
:pass
104104
else
105-
return [:warn, result.stderr + result.stdout]
105+
[:warn, result.stderr + result.stdout]
106106
end
107107
end
108108

@@ -137,12 +137,14 @@ def modified_cookbooks_args
137137

138138
def modified(type)
139139
return [] if !config["#{type}_directory"] || config["#{type}_directory"].empty?
140+
140141
@modified ||= {}
141142
@modified[type] ||= directories_changed(full_directory_path("#{type}_directory"))
142143
end
143144

144145
def full_directory_path(config_option)
145146
return config[config_option] if config[config_option].start_with?(File::SEPARATOR)
147+
146148
File.absolute_path(File.join(Overcommit::Utils.repo_root, config[config_option]))
147149
end
148150
end

lib/overcommit/hook/pre_commit/hlint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Hlint < Base
1010
:(?<line>\d+)
1111
:\d+
1212
:\s*(?<type>\w+)
13-
/x
13+
/x.freeze
1414

1515
MESSAGE_TYPE_CATEGORIZER = lambda do |type|
1616
type.include?('W') ? :warning : :error

lib/overcommit/hook/pre_commit/html_tidy.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class HtmlTidy < Base
1010
line\s(?<line>\d+)\s
1111
column\s(?<col>\d+)\s-\s
1212
(?<type>Error|Warning):\s(?<message>.+)$
13-
/x
13+
/x.freeze
1414

1515
def run
1616
# example message:

lib/overcommit/hook/pre_commit/java_checkstyle.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Overcommit::Hook::PreCommit
55
#
66
# @see http://checkstyle.sourceforge.net/
77
class JavaCheckstyle < Base
8-
MESSAGE_REGEX = /^(\[(?<type>[^\]]+)\]\s+)?(?<file>(?:\w:)?[^:]+):(?<line>\d+)/
8+
MESSAGE_REGEX = /^(\[(?<type>[^\]]+)\]\s+)?(?<file>(?:\w:)?[^:]+):(?<line>\d+)/.freeze
99

1010
MESSAGE_TYPE_CATEGORIZER = lambda do |type|
1111
%w[WARN INFO].include?(type.to_s) ? :warning : :error

lib/overcommit/hook/pre_commit/js_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Overcommit::Hook::PreCommit
55
#
66
# @see http://www.jslint.com/
77
class JsLint < Base
8-
MESSAGE_REGEX = /(?<file>(?:\w:)?[^:]+):(?<line>\d+)/
8+
MESSAGE_REGEX = /(?<file>(?:\w:)?[^:]+):(?<line>\d+)/.freeze
99

1010
def run
1111
result = execute(command, args: applicable_files)

lib/overcommit/hook/pre_commit/jsl.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Overcommit::Hook::PreCommit
55
#
66
# @see http://www.javascriptlint.com/
77
class Jsl < Base
8-
MESSAGE_REGEX = /(?<file>(?:\w:)?.+)\((?<line>\d+)\):(?<type>[^:]+)/
8+
MESSAGE_REGEX = /(?<file>(?:\w:)?.+)\((?<line>\d+)\):(?<type>[^:]+)/.freeze
99

1010
MESSAGE_TYPE_CATEGORIZER = lambda do |type|
1111
type.match?(/warning/) ? :warning : :error

lib/overcommit/hook/pre_commit/kt_lint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Overcommit::Hook::PreCommit
44
# Runs `ktlint` against modified Kotlin files.
55
# @see https://github.com/shyiko/ktlint
66
class KtLint < Base
7-
MESSAGE_REGEX = /((?<file>[^:]+):(?<line>\d+):(\d+):(?<message>.+))/
7+
MESSAGE_REGEX = /((?<file>[^:]+):(?<line>\d+):(\d+):(?<message>.+))/.freeze
88

99
def run
1010
result = execute(command, args: applicable_files)

lib/overcommit/hook/pre_commit/license_finder.rb

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class LicenseFinder < Base
77
def run
88
result = execute(command)
99
return :pass if result.success?
10+
1011
output = result.stdout + result.stderr
1112
[:fail, output]
1213
end

0 commit comments

Comments
 (0)