Skip to content

Commit

Permalink
Chore: RuboCop Style/MultipleComparison
Browse files Browse the repository at this point in the history
This fixes the single instance of the offense for MultipleComparison.
It turned out that the code wasn't needed at all, since
`Faraday::Utils.escape` already correctly stringifies booleans.

I also added a unit test that seemed to be missing for this code.
  • Loading branch information
Drenmi committed Mar 4, 2019
1 parent c209c41 commit ef2f4fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
7 changes: 1 addition & 6 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-03-04 02:27:02 +0900 using RuboCop version 0.65.0.
# on 2019-03-04 10:37:51 +0800 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 @@ -135,11 +135,6 @@ Style/MultilineIfModifier:
- 'test/adapters/em_http_test.rb'
- 'test/helper.rb'

# Offense count: 1
Style/MultipleComparison:
Exclude:
- 'lib/faraday/encoders/flat_params_encoder.rb'

# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand Down
1 change: 0 additions & 1 deletion lib/faraday/encoders/flat_params_encoder.rb
Expand Up @@ -29,7 +29,6 @@ def self.encode(params)
buffer = +''
params.each do |key, value|
encoded_key = escape(key)
value = value.to_s if value == true || value == false
if value.nil?
buffer << "#{encoded_key}&"
elsif value.is_a?(Array)
Expand Down
6 changes: 6 additions & 0 deletions spec/faraday/params_encoders/flat_spec.rb
Expand Up @@ -10,4 +10,10 @@
expected = { 'a' => %w[one two three] }
expect(subject.decode(query)).to eq(expected)
end

it 'decodes boolean values' do
query = 'a=true&b=false'
expected = { 'a' => 'true', 'b' => 'false' }
expect(subject.decode(query)).to eq(expected)
end
end

0 comments on commit ef2f4fa

Please sign in to comment.