Skip to content

Commit

Permalink
chore: Fix RuboCop Style/ZeroLengthPredicate (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
olleolleolle committed Feb 20, 2019
1 parent 1054fcd commit b585462
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
17 changes: 4 additions & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-02-20 22:01:31 +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
Expand Down Expand Up @@ -827,13 +827,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'
Expand Down Expand Up @@ -872,7 +873,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
Expand All @@ -881,9 +882,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'
Expand Down Expand Up @@ -1171,14 +1170,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
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/adapter/em_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/faraday/adapter/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b585462

Please sign in to comment.