From e76d69f16e9f54ba40a26cbf9482b200bca0892d Mon Sep 17 00:00:00 2001 From: Steve Richert Date: Mon, 22 Apr 2024 02:24:39 +0000 Subject: [PATCH] Update RuboCop and generate a to-do --- .github/workflows/rake.yml | 2 +- .rubocop.yml | 25 +++++---- .rubocop_todo.yml | 104 +++++++++++++++++++++++++++++++++++++ Gemfile | 4 +- lib/rspec/wait/handler.rb | 2 +- lib/rspec/wait/target.rb | 8 ++- rspec-wait.gemspec | 2 +- 7 files changed, 129 insertions(+), 18 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.github/workflows/rake.yml b/.github/workflows/rake.yml index 3529476..9200bb4 100644 --- a/.github/workflows/rake.yml +++ b/.github/workflows/rake.yml @@ -45,4 +45,4 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - name: Run tests - run: bundle exec rspec + run: bundle exec rake diff --git a/.rubocop.yml b/.rubocop.yml index 2691645..b528f8f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..a39726c --- /dev/null +++ b/.rubocop_todo.yml @@ -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 diff --git a/Gemfile b/Gemfile index b5a600d..217e9c6 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/lib/rspec/wait/handler.rb b/lib/rspec/wait/handler.rb index 87c3e22..a163606 100644 --- a/lib/rspec/wait/handler.rb +++ b/lib/rspec/wait/handler.rb @@ -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 diff --git a/lib/rspec/wait/target.rb b/lib/rspec/wait/target.rb index 57fde85..2d8f78b 100644 --- a/lib/rspec/wait/target.rb +++ b/lib/rspec/wait/target.rb @@ -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) diff --git a/rspec-wait.gemspec b/rspec-wait.gemspec index 0ddbe91..913702b 100644 --- a/rspec-wait.gemspec +++ b/rspec-wait.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |spec| spec.email = "steve.richert@gmail.com" 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"