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

[Fix #180] Fix a false positive for HttpPositionalArguments #194

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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