Skip to content

Commit

Permalink
Update RuboCop (#818)
Browse files Browse the repository at this point in the history
The current version of Ruby is from April 2020. Since there are quite a
lot of new issues identified, I've committed them to the
`.rubocop_todo.yml` so that they can be addressed incrementally or
disabled.

Co-authored-by: Andy Waite <[email protected]>
  • Loading branch information
andyw8 and andyw8 authored Jan 15, 2024
1 parent 4f11048 commit faf76fc
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.4

Expand Down
137 changes: 137 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit`
# on 2024-01-10 14:09:00 UTC using RuboCop version 1.59.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowAliasSyntax, AllowedMethods.
# AllowedMethods: alias_method, public, protected, private
Layout/EmptyLinesAroundAttributeAccessor:
Exclude:
- 'lib/overcommit/hook_context/post_merge.rb'

# Offense count: 6
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/overcommit/message_processor_spec.rb'

# Offense count: 4
Lint/MixedRegexpCaptureTypes:
Exclude:
- 'lib/overcommit/hook/pre_commit/dart_analyzer.rb'
- 'lib/overcommit/hook/pre_commit/java_checkstyle.rb'
- 'lib/overcommit/hook/pre_commit/kt_lint.rb'
- 'lib/overcommit/hook/pre_commit/scalastyle.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Lint/RedundantCopDisableDirective:
Exclude:
- 'lib/overcommit/hook_runner.rb'
- 'lib/overcommit/printer.rb'

# Offense count: 1
# Configuration parameters: CountComments, Max, CountAsOne.
Metrics/ClassLength:
Exclude:
- 'lib/overcommit/utils.rb'

# Offense count: 2
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/CyclomaticComplexity:
Exclude:
- 'lib/overcommit/configuration.rb'
- 'lib/overcommit/hook_runner.rb'

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/PerceivedComplexity:
Exclude:
- 'lib/overcommit/configuration.rb'
- 'lib/overcommit/configuration_validator.rb'
- 'lib/overcommit/hook_runner.rb'

# Offense count: 23
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'bin/overcommit'
- 'lib/overcommit/hook/post_commit/git_guilt.rb'
- 'template-dir/hooks/commit-msg'
- 'template-dir/hooks/overcommit-hook'
- 'template-dir/hooks/post-checkout'
- 'template-dir/hooks/post-commit'
- 'template-dir/hooks/post-merge'
- 'template-dir/hooks/post-rewrite'
- 'template-dir/hooks/pre-commit'
- 'template-dir/hooks/pre-push'
- 'template-dir/hooks/pre-rebase'
- 'template-dir/hooks/prepare-commit-msg'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformValues:
Exclude:
- 'lib/overcommit/configuration.rb'
- 'lib/overcommit/configuration_validator.rb'

# Offense count: 1
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/overcommit/logger.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantBegin:
Exclude:
- 'lib/overcommit/hook/prepare_commit_msg/replace_branch.rb'
- 'lib/overcommit/utils.rb'

# Offense count: 10
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SafeForConstants.
Style/RedundantFetchBlock:
Exclude:
- 'lib/overcommit/configuration.rb'
- 'lib/overcommit/configuration_validator.rb'
- 'lib/overcommit/hook/base.rb'
- 'lib/overcommit/hook/pre_commit/chamber_verification.rb'
- 'lib/overcommit/logger.rb'
- 'spec/support/shell_helpers.rb'

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
Exclude:
- 'lib/overcommit/configuration.rb'
- 'lib/overcommit/hook/pre_commit/php_cs.rb'
- 'lib/overcommit/hook/pre_commit/php_lint.rb'
- 'lib/overcommit/hook/pre_commit/php_stan.rb'

# Offense count: 15
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/overcommit/hook/pre_commit/bundle_check.rb'
- 'lib/overcommit/hook_runner.rb'
- 'lib/overcommit/message_processor.rb'
- 'spec/integration/gemfile_option_spec.rb'
- 'spec/overcommit/hook/commit_msg/text_width_spec.rb'
- 'spec/overcommit/hook/prepare_commit_msg/base_spec.rb'
- 'spec/overcommit/message_processor_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/ZeroLengthPredicate:
Exclude:
- 'lib/overcommit/hook/pre_commit/ruby_syntax.rb'
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gem 'rspec', '~> 3.0'
gem 'simplecov', '~> 0.21.0'
gem 'simplecov-lcov', '~> 0.8.0'

# Pin RuboCop for Travis builds.
gem 'rubocop', '0.82.0'
# Pin RuboCop for CI builds
gem 'rubocop', '1.59.0'

gem 'ffi' if Gem.win_platform?
12 changes: 6 additions & 6 deletions spec/overcommit/hook/pre_commit/phpcs_fixer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

context 'when phpcs fixer exits successfully with fixed file' do
before do
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
sample_output = [
'Loaded config default.',
'Using cache file ".php_cs.cache".',
Expand All @@ -24,7 +24,7 @@
'Fixed all files in 0.001 seconds, 10.000 MB memory used',
'',
].join("\n")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

result = double('result')
result.stub(:status).and_return(0)
Expand All @@ -38,15 +38,15 @@

context 'when phpcs fixer exits successfully with no file to fix' do
before do
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
sample_output = [
'Loaded config default.',
'Using cache file ".php_cs.cache".',
'S',
'Legend: ?-unknown, I-invalid file syntax, file ignored, S-Skipped, .-no changes, F-fixed, E-error',
'',
].join("\n")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

result = double('result')
result.stub(:status).and_return(0)
Expand All @@ -60,7 +60,7 @@

context 'when phpcs exits unsuccessfully' do
before do
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
sample_output = [
'Loaded config default.',
'Using cache file ".php_cs.cache".',
Expand All @@ -72,7 +72,7 @@
' 1) /home/damien/Code/Rezdy/php/foo/broken.php',
'',
].join("\n")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

result = double('result')
result.stub(:status).and_return(1)
Expand Down

0 comments on commit faf76fc

Please sign in to comment.