Skip to content

Commit

Permalink
Update RuboCop and generate a to-do
Browse files Browse the repository at this point in the history
  • Loading branch information
laserlemon authored Apr 22, 2024
1 parent d1331c2 commit e76d69f
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Run tests
run: bundle exec rspec
run: bundle exec rake
25 changes: 16 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-performance
- rubocop-rake

# This should always correspond to the earliest non-EOL Ruby version.
AllCops:
TargetRubyVersion: 2.2
NewCops: enable
TargetRubyVersion: 3.0

# TODO: Re-enable this cop after TomDoc code deocumentation is added.
# TODO: Re-enable this cop after TomDoc code documentation is added.
Style/Documentation:
Enabled: false

Metrics/BlockLength:
ExcludedMethods:
- context
- describe
Metrics/LineLength:
Layout/LineLength:
IgnoreCopDirectives: true
Metrics/BlockLength:
AllowedMethods:
- context
- describe
Style/BlockDelimiters:
EnforcedStyle: semantic
FunctionalMethods:
- expect
- let
- expect
- let
Style/StringLiterals:
EnforcedStyle: double_quotes
Style/SymbolArray:
Expand Down
104 changes: 104 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-04-22 02:23:45 UTC using RuboCop version 1.63.2.
# 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: Severity, Include.
# Include: **/*.gemspec
Gemspec/DeprecatedAttributeAssignment:
Exclude:
- 'rspec-wait.gemspec'

# Offense count: 2
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
# SupportedStyles: Gemfile, gems.rb, gemspec
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
Gemspec/DevelopmentDependencies:
Exclude:
- 'rspec-wait.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequireMFA:
Exclude:
- 'rspec-wait.gemspec'

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'rspec-wait.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterGuardClause:
Exclude:
- 'lib/rspec/wait/target.rb'

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 19

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 12

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'lib/rspec/wait/handler.rb'

# Offense count: 1
Rake/DuplicateTask:
Exclude:
- 'Rakefile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/ExpandPathArguments:
Exclude:
- 'rspec-wait.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/ExplicitBlockArgument:
Exclude:
- 'lib/rspec/wait/target.rb'

# Offense count: 26
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'lib/rspec/wait/target.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantBegin:
Exclude:
- 'lib/rspec/wait/handler.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 129
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ source "https://rubygems.org"

gemspec

gem "rubocop", require: false
gem "rubocop", "~> 1.63", require: false
gem "rubocop-performance", "~> 1.21", require: false
gem "rubocop-rake", "~> 0.6.0", require: false
2 changes: 1 addition & 1 deletion lib/rspec/wait/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RSpec
module Wait
module Handler
def handle_matcher(target, *args, &block) # rubocop:disable Metrics/MethodLength
def handle_matcher(target, *args, &block)
failure = nil

Timeout.timeout(RSpec.configuration.wait_timeout) do
Expand Down
8 changes: 3 additions & 5 deletions lib/rspec/wait/target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ class Target < RSpec::Expectations::ExpectationTarget
UndefinedValue = Module.new

# From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L30-L41
# rubocop:disable Metrics/MethodLength
def self.for(value, block, options = {})
if UndefinedValue.equal?(value)
unless block
raise ArgumentError, "You must pass either an argument or a block to `wait_for`." # rubocop:disable Metrics/LineLength
raise ArgumentError, "You must pass either an argument or a block to `wait_for`."
end
new(block, options)
elsif block
raise ArgumentError, "You cannot pass both an argument and a block to `wait_for`." # rubocop:disable Metrics/LineLength
raise ArgumentError, "You cannot pass both an argument and a block to `wait_for`."
else
warn "[DEPRECATION] As of rspec-wait version 1.0, neither wait_for nor wait.for will accept an argument, only a block." # rubocop:disable Metrics/LineLength
warn "[DEPRECATION] As of rspec-wait version 1.0, neither wait_for nor wait.for will accept an argument, only a block."
new(value, options)
end
end
# rubocop:enable Metrics/MethodLength

# From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L25-L27
def initialize(target, options)
Expand Down
2 changes: 1 addition & 1 deletion rspec-wait.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.email = "[email protected]"

spec.summary = "Wait for conditions in RSpec"
spec.description = "RSpec::Wait enables time-resilient expectations in your RSpec test suite." # rubocop:disable Metrics/LineLength
spec.description = "RSpec::Wait enables time-resilient expectations in your RSpec test suite."
spec.homepage = "https://github.com/laserlemon/rspec-wait"
spec.license = "MIT"

Expand Down

0 comments on commit e76d69f

Please sign in to comment.