Skip to content

Commit

Permalink
Fix an error for Rails/UniqueValidationWithoutIndex
Browse files Browse the repository at this point in the history
This PR is fix an error for `Rails/UniqueValidationWithoutIndex`.
  • Loading branch information
ydah committed Jun 18, 2023
1 parent b45aef9 commit 8fef179
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#x](https://github.com/rubocop/rubocop-rails/pull/x): Fix an error for `Rails/UniqueValidationWithoutIndex`. ([@ydah][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/unique_validation_without_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class UniqueValidationWithoutIndex < Base
RESTRICT_ON_SEND = %i[validates].freeze

def on_send(node)
return if uniqueness_part(node).falsey_literal?
return if uniqueness_part(node)&.falsey_literal?
return if condition_part?(node)
return unless schema

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
expect_no_offenses(<<~RUBY)
class User < ApplicationRecord
validates :account, uniqueness: true
validates :name, presence: true
end
RUBY
end
Expand Down

0 comments on commit 8fef179

Please sign in to comment.