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

Add missing absence validations to Rails/Validation #6941

Merged
merged 2 commits into from Apr 17, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@

* Do not annotate message with cop name in JSON output. ([@elebow][])
* [#6914](https://github.com/rubocop-hq/rubocop/issues/6914): [Fix #6914] Fix an error for `Rails/RedundantAllowNil` when with interpolations. ([@Blue-Pix][])
* [#6941](https://github.com/rubocop-hq/rubocop/issues/6941): Add missing absence validations to `Rails/Validation`. ([@jmanian][])

### Changes

Expand Down Expand Up @@ -3946,3 +3947,4 @@
[@thomthom]: https://github.com/thomthom
[@Blue-Pix]: https://github.com/Blue-Pix
[@Mange]: https://github.com/Mange
[@jmanian]: https://github.com/jmanian
3 changes: 3 additions & 0 deletions lib/rubocop/cop/rails/validation.rb
Expand Up @@ -15,6 +15,7 @@ module Rails
# validates_length_of :foo
# validates_numericality_of :foo
# validates_presence_of :foo
# validates_absence_of :foo
# validates_size_of :foo
# validates_uniqueness_of :foo
#
Expand All @@ -27,6 +28,7 @@ module Rails
# validates :foo, length: true
# validates :foo, numericality: true
# validates :foo, presence: true
# validates :foo, absence: true
# validates :foo, size: true
# validates :foo, uniqueness: true
#
Expand All @@ -43,6 +45,7 @@ class Validation < Cop
length
numericality
presence
absence
size
uniqueness
].freeze
Expand Down
2 changes: 2 additions & 0 deletions manual/cops_rails.md
Expand Up @@ -2350,6 +2350,7 @@ validates_inclusion_of :foo
validates_length_of :foo
validates_numericality_of :foo
validates_presence_of :foo
validates_absence_of :foo
validates_size_of :foo
validates_uniqueness_of :foo

Expand All @@ -2362,6 +2363,7 @@ validates :foo, inclusion: true
validates :foo, length: true
validates :foo, numericality: true
validates :foo, presence: true
validates :foo, absence: true
validates :foo, size: true
validates :foo, uniqueness: true
```
Expand Down