Skip to content

Commit

Permalink
[Fix rubocop#5888] Do not register an offense for headers or env keyw…
Browse files Browse the repository at this point in the history
…ord args
  • Loading branch information
rrosenblum committed May 16, 2018
1 parent 6cdd888 commit cb0b1f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#5888](https://github.com/bbatsov/rubocop/issues/5888): Do not register an offense for `headers` or `env` keyword arguments in `Rails/HttpPositionalArguments`. ([@rrosenblum][])

## 0.56.0 (2018-05-14)

### New features
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/http_positional_arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HttpPositionalArguments < Cop
MSG = 'Use keyword arguments instead of ' \
'positional arguments for http call: `%<verb>s`.'.freeze
KEYWORD_ARGS = %i[
method params session body flash xhr as
method params session body flash xhr as headers env
].freeze
HTTP_METHODS = %i[get post put patch delete head].freeze

Expand Down
8 changes: 7 additions & 1 deletion spec/rubocop/cop/rails/http_positional_arguments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@
end

[
'method: :get',
'params: { user_id: @user.id }',
'xhr: true',
'session: { foo: \'bar\' }',
'format: :json'
'format: :json',
'headers: {}',
'body: "foo"',
'flash: {}',
'as: :json',
'env: "test"'
].each do |keyword_args|
describe "when using keyword args #{keyword_args}" do
it 'does not register an offense' do
Expand Down

0 comments on commit cb0b1f3

Please sign in to comment.