Skip to content

Commit 171e6de

Browse files
authored
Merge pull request #1279 from tldn0718/fix-skip-model-validation-safe-navigator
[Fix #1278] Fix a false positivie for Rails/SkipsModelValidations
2 parents 582af1e + 40d9dc3 commit 171e6de

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1278](https://github.com/rubocop/rubocop-rails/issues/1278): Fix a false positive for `Rails/SkipsModelValidations` when using `insert` or `insert!` with a safe navigator. ([@tldn0718][])

lib/rubocop/cop/rails/skips_model_validations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class SkipsModelValidations < Base
6363
PATTERN
6464

6565
def_node_matcher :good_insert?, <<~PATTERN
66-
(send _ {:insert :insert!} _ {
66+
(call _ {:insert :insert!} _ {
6767
!(hash ...)
6868
(hash <(pair (sym !{:returning :unique_by}) _) ...>)
6969
} ...)

spec/rubocop/cop/rails/skips_model_validations_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@
5757
it "does not register an offense for #{method} that looks like String#insert" do
5858
expect_no_offenses(<<~RUBY)
5959
string.#{method}(0, 'b')
60+
string&.#{method}(0, 'b')
6061
RUBY
6162
end
6263

6364
it "does not register an offense for #{method} that looks like Array#insert" do
6465
expect_no_offenses(<<~RUBY)
6566
array.#{method}(1, :a, :b)
67+
array&.#{method}(1, :a, :b)
6668
RUBY
6769
end
6870

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy