-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Wrong autocorrect for Rails/Validation #118
Labels
bug
Something isn't working
Comments
geniou
changed the title
wrong autocorrect of Rails/Validation
Wrong autocorrect for Rails/Validation
Aug 27, 2019
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Aug 27, 2019
Fixes rubocop#118. This PR fixes an incorrect autocorrect for `Rails/Validation` when attributes are specified with symbol array literal. The following auto-corrected causes `NoMethodError`. ```ruby validates %i[full_name birth_date], presence: true # => validates_with': undefined method `to_sym' for # [:full_name, :birth_date]:Array (NoMethodError) ``` This PR will auto-corrected to the following code. ```ruby validates :full_name, :birth_date, presence: true ```
8 tasks
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Aug 27, 2019
Fixes rubocop#118. This PR fixes an incorrect autocorrect for `Rails/Validation` when attributes are specified with symbol array literal. The following auto-corrected causes `NoMethodError`. ```ruby validates %i[full_name birth_date], presence: true # => validates_with': undefined method `to_sym' for # [:full_name, :birth_date]:Array (NoMethodError) ``` This PR will auto-correct it to the following code. ```ruby validates :full_name, :birth_date, presence: true ```
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Aug 28, 2019
Fixes rubocop#118. This PR fixes an incorrect autocorrect for `Rails/Validation` when attributes are specified with symbol array literal. The following auto-corrected causes `NoMethodError`. ```ruby validates %i[full_name birth_date], presence: true # => validates_with': undefined method `to_sym' for # [:full_name, :birth_date]:Array (NoMethodError) ``` This PR will auto-correct it to the following code. ```ruby validates :full_name, :birth_date, presence: true ```
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Aug 28, 2019
Fixes rubocop#118. This PR fixes an incorrect autocorrect for `Rails/Validation` when attributes are specified with symbol array literal. The following auto-corrected causes `NoMethodError`. ```ruby validates %i[full_name birth_date], presence: true # => validates_with': undefined method `to_sym' for # [:full_name, :birth_date]:Array (NoMethodError) ``` This PR will auto-correct it to the following code. ```ruby validates :full_name, :birth_date, presence: true ```
koic
added a commit
that referenced
this issue
Aug 31, 2019
…ils_validation [Fix #118] Fix an incorrect autocorrect for `Rails/Validation`
RuboCop Rails 2.3.2 has been released to resolve this issue. Thank you. |
@koic thank you! That was quick. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When running the auto correct of
Rails/Validation
is producing invalid code.Expected behavior
validates_presence_of %i[foo bar]
should be corrected tovalidates :foo, :bar, presence: true
or skipped.Actual behavior
Got corrected to
validates %i[foo bar], presence: true
which is invalid and fails withundefined method
to_sym' for #Array:0x0000000009efab88`Steps to reproduce the problem
see code snippets
RuboCop version
0.74.0 (using Parser 2.6.3.0, running on ruby 2.6.3 x86_64-darwin18)
The text was updated successfully, but these errors were encountered: