From de02e14ec1d691a794e6ae7673ba91d151aaf7fb Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Wed, 20 Feb 2019 22:06:30 +0100 Subject: [PATCH] chore: Fix RuboCop Style/ZeroLengthPredicate --- .rubocop_todo.yml | 17 ++++------------- lib/faraday/adapter/em_http.rb | 2 +- lib/faraday/adapter/test.rb | 4 ++-- lib/faraday/options.rb | 2 +- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4989a2fa0..dfa6a461a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-02-20 19:56:42 +0100 using RuboCop version 0.65.0. +# on 2019-02-20 22:05:38 +0100 using RuboCop version 0.65.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 @@ -835,13 +835,14 @@ Style/MutableConstant: - 'lib/faraday/response/raise_error.rb' - 'lib/faraday/utils.rb' -# Offense count: 8 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: both, prefix, postfix Style/NegatedIf: Exclude: - 'lib/faraday.rb' + - 'lib/faraday/adapter/em_http.rb' - 'lib/faraday/adapter/test.rb' - 'lib/faraday/connection.rb' - 'lib/faraday/encoders/flat_params_encoder.rb' @@ -880,7 +881,7 @@ Style/Not: - 'lib/faraday/adapter/em_http.rb' - 'lib/faraday/response.rb' -# Offense count: 11 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison @@ -889,9 +890,7 @@ Style/NumericPredicate: - 'spec/**/*' - 'lib/faraday/adapter/em_http.rb' - 'lib/faraday/adapter/net_http.rb' - - 'lib/faraday/adapter/test.rb' - 'lib/faraday/encoders/nested_params_encoder.rb' - - 'lib/faraday/options.rb' - 'lib/faraday/request/retry.rb' - 'lib/faraday/upload_io.rb' - 'lib/faraday/utils/headers.rb' @@ -1179,14 +1178,6 @@ Style/YodaCondition: - 'script/proxy-server' - 'test/helper.rb' -# Offense count: 4 -# Cop supports --auto-correct. -Style/ZeroLengthPredicate: - Exclude: - - 'lib/faraday/adapter/em_http.rb' - - 'lib/faraday/adapter/test.rb' - - 'lib/faraday/options.rb' - # Offense count: 267 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https diff --git a/lib/faraday/adapter/em_http.rb b/lib/faraday/adapter/em_http.rb index 8f449adc0..a569f6778 100644 --- a/lib/faraday/adapter/em_http.rb +++ b/lib/faraday/adapter/em_http.rb @@ -225,7 +225,7 @@ def run perform_request(&proc) end end - if @errors.size > 0 + if !@errors.empty? raise Faraday::ClientError, @errors.first || "connection failed" end end diff --git a/lib/faraday/adapter/test.rb b/lib/faraday/adapter/test.rb index 17ca26278..1ec70f96b 100644 --- a/lib/faraday/adapter/test.rb +++ b/lib/faraday/adapter/test.rb @@ -98,13 +98,13 @@ def options(path, headers = {}, &block) def verify_stubbed_calls failed_stubs = [] @stack.each do |method, stubs| - unless stubs.size == 0 + unless stubs.empty? failed_stubs.concat(stubs.map {|stub| "Expected #{method} #{stub}." }) end end - raise failed_stubs.join(" ") unless failed_stubs.size == 0 + raise failed_stubs.join(" ") unless failed_stubs.empty? end protected diff --git a/lib/faraday/options.rb b/lib/faraday/options.rb index 5e8ecac50..e04f8246c 100644 --- a/lib/faraday/options.rb +++ b/lib/faraday/options.rb @@ -69,7 +69,7 @@ def deep_dup def fetch(key, *args) unless symbolized_key_set.include?(key.to_sym) key_setter = "#{key}=" - if args.size > 0 + if !args.empty? send(key_setter, args.first) elsif block_given? send(key_setter, Proc.new.call(key))