mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-06 00:03:36 -04:00
Merge pull request #896 from lostisland/fix-more-lint-offenses
fix Lint/* offenses
This commit is contained in:
commit
c2719dc5cb
@ -6,50 +6,6 @@
|
||||
# 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
|
||||
Lint/HandleExceptions:
|
||||
Exclude:
|
||||
- 'test/adapters/rack_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Lint/ReturnInVoidContext:
|
||||
Exclude:
|
||||
- 'lib/faraday/options/env.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Lint/UnneededRequireStatement:
|
||||
Exclude:
|
||||
- 'lib/faraday.rb'
|
||||
- 'lib/faraday/utils.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
||||
Lint/UnusedBlockArgument:
|
||||
Exclude:
|
||||
- 'lib/faraday/encoders/nested_params_encoder.rb'
|
||||
- 'lib/faraday/request/retry.rb'
|
||||
- 'spec/faraday/options/options_spec.rb'
|
||||
- 'test/adapters/test_middleware_test.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
||||
Lint/UnusedMethodArgument:
|
||||
Exclude:
|
||||
- 'lib/faraday/adapter.rb'
|
||||
- 'lib/faraday/adapter/em_http.rb'
|
||||
- 'lib/faraday/adapter/em_synchrony.rb'
|
||||
- 'script/generate_certs'
|
||||
- 'spec/faraday/response/middleware_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: CheckForMethodsWithNoSideEffects.
|
||||
Lint/Void:
|
||||
Exclude:
|
||||
- 'lib/faraday/connection.rb'
|
||||
|
||||
# Offense count: 41
|
||||
Metrics/AbcSize:
|
||||
Max: 86
|
||||
@ -63,7 +19,7 @@ Metrics/BlockLength:
|
||||
# Offense count: 5
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ClassLength:
|
||||
Max: 217
|
||||
Max: 216
|
||||
|
||||
# Offense count: 20
|
||||
Metrics/CyclomaticComplexity:
|
||||
|
@ -1,6 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'thread'
|
||||
require 'cgi'
|
||||
require 'set'
|
||||
require 'forwardable'
|
||||
|
@ -35,7 +35,7 @@ module Faraday
|
||||
extend Parallelism
|
||||
self.supports_parallel = false
|
||||
|
||||
def initialize(app = nil, opts = {}, &block)
|
||||
def initialize(_app = nil, opts = {}, &block)
|
||||
@app = lambda { |env| env.response }
|
||||
@connection_options = opts
|
||||
@config_block = block
|
||||
|
@ -90,7 +90,7 @@ module Faraday
|
||||
self.supports_parallel = true
|
||||
|
||||
# @return [Manager]
|
||||
def self.setup_parallel_manager(options = nil)
|
||||
def self.setup_parallel_manager(_options = nil)
|
||||
Manager.new
|
||||
end
|
||||
|
||||
|
@ -17,7 +17,7 @@ module Faraday
|
||||
self.supports_parallel = true
|
||||
|
||||
# @return [ParallelManager]
|
||||
def self.setup_parallel_manager(options = {})
|
||||
def self.setup_parallel_manager(_options = nil)
|
||||
ParallelManager.new
|
||||
end
|
||||
|
||||
|
@ -403,8 +403,6 @@ module Faraday
|
||||
# conn.path_prefix # => "/api"
|
||||
#
|
||||
# conn.get("nigiri?page=2") # accesses https://sushi.com/api/nigiri
|
||||
#
|
||||
# @return [URI] the parsed URI from the given input
|
||||
def url_prefix=(url, encoder = nil)
|
||||
uri = @url_prefix = Utils.URI(url)
|
||||
self.path_prefix = uri.path
|
||||
@ -416,8 +414,6 @@ module Faraday
|
||||
basic_auth user, password
|
||||
uri.user = uri.password = nil
|
||||
end
|
||||
|
||||
uri
|
||||
end
|
||||
|
||||
# Sets the path prefix and ensures that it always has a leading
|
||||
|
@ -52,7 +52,7 @@ module Faraday
|
||||
return new_parent if value.empty?
|
||||
|
||||
buffer = +''
|
||||
value.each_with_index do |val, i|
|
||||
value.each do |val|
|
||||
buffer << "#{to_query.call(new_parent, val)}&"
|
||||
end
|
||||
return buffer.chop
|
||||
|
@ -92,7 +92,10 @@ module Faraday
|
||||
# @param key [Object]
|
||||
# @param value [Object]
|
||||
def []=(key, value)
|
||||
return super(current_body, value) if key == :body
|
||||
if key == :body
|
||||
super(current_body, value)
|
||||
return
|
||||
end
|
||||
|
||||
if in_member_set?(key)
|
||||
super(key, value)
|
||||
|
@ -29,7 +29,7 @@ module Faraday
|
||||
:backoff_factor, :exceptions, :methods, :retry_if, :retry_block,
|
||||
:retry_statuses)
|
||||
|
||||
DEFAULT_CHECK = lambda { |env, exception| false }
|
||||
DEFAULT_CHECK = lambda { |_env, _exception| false }
|
||||
|
||||
def self.from(value)
|
||||
if Integer === value
|
||||
|
@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'thread'
|
||||
|
||||
require 'faraday/utils/headers'
|
||||
require 'faraday/utils/params_hash'
|
||||
|
||||
|
@ -11,7 +11,7 @@ $shell = ARGV.include? '-s'
|
||||
|
||||
# Adapted from WEBrick::Utils. Skips cert extensions so it
|
||||
# can be used as a CA bundle
|
||||
def create_self_signed_cert(bits, cname, comment)
|
||||
def create_self_signed_cert(bits, cname, _comment)
|
||||
rsa = OpenSSL::PKey::RSA.new(bits)
|
||||
cert = OpenSSL::X509::Certificate.new
|
||||
cert.version = 2
|
||||
|
@ -255,7 +255,7 @@ RSpec.describe Faraday::Options do
|
||||
|
||||
context 'when the fetched key has no value' do
|
||||
it 'uses falsey default' do
|
||||
expect(subject.fetch(:sub_a, false) { |k| :blah }).to be_falsey
|
||||
expect(subject.fetch(:sub_a, false) { |_| :blah }).to be_falsey
|
||||
end
|
||||
|
||||
it 'accepts block' do
|
||||
@ -273,7 +273,7 @@ RSpec.describe Faraday::Options do
|
||||
end
|
||||
|
||||
it 'grabs value' do
|
||||
expect(subject.fetch(:sub_a, false) { |k| :blah }).to eq(1)
|
||||
expect(subject.fetch(:sub_a, false) { |_| :blah }).to eq(1)
|
||||
end
|
||||
|
||||
it 'works with key' do
|
||||
|
@ -29,7 +29,7 @@ RSpec.describe Faraday::Response::Middleware do
|
||||
context 'with a custom ResponseMiddleware but empty response' do
|
||||
let(:custom_middleware) do
|
||||
Class.new(Faraday::Response::Middleware) do
|
||||
def parse(body)
|
||||
def parse(_body)
|
||||
raise 'this should not be called'
|
||||
end
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ module Adapters
|
||||
conn = create_connection(request: { timeout: 1, open_timeout: 1 })
|
||||
begin
|
||||
conn.get '/slow'
|
||||
rescue Faraday::ClientError
|
||||
rescue Faraday::ClientError # rubocop:disable Lint/HandleExceptions
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ module Adapters
|
||||
stub.get(/\A\/resources\/\d+(?:\?|\z)/) do
|
||||
[200, { 'Content-Type' => 'text/html' }, 'show']
|
||||
end
|
||||
stub.get(/\A\/resources\/(specified)\z/) do |env, meta|
|
||||
stub.get(/\A\/resources\/(specified)\z/) do |_env, meta|
|
||||
[200, { 'Content-Type' => 'text/html' }, "show #{meta[:match_data][1]}"]
|
||||
end
|
||||
stub.get('http://domain.test/hello') do
|
||||
|
Loading…
x
Reference in New Issue
Block a user