Skip to content

Commit

Permalink
Merge pull request #194 from koic/fix_a_false_positive_for_http_posit…
Browse files Browse the repository at this point in the history
…ional_arguments

[Fix #180] Fix a false positive for `HttpPositionalArguments`
  • Loading branch information
koic authored Feb 2, 2020
2 parents afbd115 + f24fae8 commit 511ebea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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

* [#180](https://github.com/rubocop-hq/rubocop-rails/issues/180): Fix a false positive for `HttpPositionalArguments` when using `get` method with `:to` option. ([@koic][])

## 2.4.2 (2020-01-26)

### Bug fixes
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`.'
KEYWORD_ARGS = %i[
method params session body flash xhr as headers env
method params session body flash xhr as headers env to
].freeze
HTTP_METHODS = %i[get post put patch delete head].freeze

Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/rails/http_positional_arguments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
RUBY
end

it 'registers an offense for get method with `:to` option' do
expect_no_offenses(<<~RUBY)
get '/test', to: 'admin/admin#test'
RUBY
end

it 'registers an offense for post method' do
expect_offense(<<~RUBY)
post :create, user_id: @user.id
Expand Down

0 comments on commit 511ebea

Please sign in to comment.