File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ def on_send(node)
67
67
68
68
add_offense ( node , location : :selector )
69
69
end
70
+ alias on_csend on_send
70
71
71
72
private
72
73
Original file line number Diff line number Diff line change 77
77
^^^^^^^^^^^^^^^^ Avoid using `update_attribute` because it skips validations.
78
78
RUBY
79
79
end
80
+
81
+ context 'when using safe navigation operator' , :ruby23 do
82
+ it 'registers an offense for `update_attribute`' do
83
+ expect_offense ( <<-RUBY . strip_indent )
84
+ user&.update_attribute(:website, 'example.com')
85
+ ^^^^^^^^^^^^^^^^ Avoid using `update_attribute` because it skips validations.
86
+ RUBY
87
+ end
88
+ end
80
89
end
81
90
82
91
context 'with whitelist' do
94
103
RUBY
95
104
end
96
105
106
+ context 'when using safe navigation operator' , :ruby23 do
107
+ it 'registers an offense for method not in whitelist' do
108
+ expect_offense ( <<-RUBY . strip_indent )
109
+ user&.toggle!(:active)
110
+ ^^^^^^^ Avoid using `toggle!` because it skips validations.
111
+ RUBY
112
+ end
113
+ end
114
+
97
115
it 'accepts method in whitelist, superseding the blacklist' do
98
116
expect_no_offenses ( 'User.touch(:attr)' )
99
117
end
You can’t perform that action at this time.
0 commit comments