Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix RuboCop Style/ZeroLengthPredicate #858

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 4 additions & 13 deletions .rubocop_todo.yml
@@ -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
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
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
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