13
13
RUBY
14
14
end
15
15
16
- it 'registers and corrects an offense when using `reject { |e| e.empty? }`' do
17
- expect_offense ( <<~RUBY )
18
- collection.reject { |e| e.empty? }
19
- ^^^^^^^^^^^^^^^^^^^^^^^ Use `compact_blank` instead.
20
- RUBY
21
-
22
- expect_correction ( <<~RUBY )
23
- collection.compact_blank
24
- RUBY
25
- end
26
-
27
16
it 'registers and corrects an offense when using `reject(&:blank?)`' do
28
17
expect_offense ( <<~RUBY )
29
18
collection.reject(&:blank?)
35
24
RUBY
36
25
end
37
26
38
- it 'registers and corrects an offense when using `reject(&:empty?)`' do
39
- expect_offense ( <<~RUBY )
40
- collection.reject(&:empty?)
41
- ^^^^^^^^^^^^^^^^ Use `compact_blank` instead.
42
- RUBY
43
-
44
- expect_correction ( <<~RUBY )
45
- collection.compact_blank
46
- RUBY
47
- end
48
-
49
27
it 'registers and corrects an offense when using `reject! { |e| e.blank? }`' do
50
28
expect_offense ( <<~RUBY )
51
29
collection.reject! { |e| e.blank? }
57
35
RUBY
58
36
end
59
37
60
- it 'registers and corrects an offense when using `reject! { |e| e.empty? }`' do
61
- expect_offense ( <<~RUBY )
62
- collection.reject! { |e| e.empty? }
63
- ^^^^^^^^^^^^^^^^^^^^^^^^ Use `compact_blank!` instead.
64
- RUBY
65
-
66
- expect_correction ( <<~RUBY )
67
- collection.compact_blank!
68
- RUBY
69
- end
70
-
71
38
it 'registers and corrects an offense when using `reject!(&:blank?)`' do
72
39
expect_offense ( <<~RUBY )
73
40
collection.reject!(&:blank?)
79
46
RUBY
80
47
end
81
48
82
- it 'registers and corrects an offense when using `reject!(&:empty?)`' do
83
- expect_offense ( <<~RUBY )
84
- collection.reject!(&:empty?)
85
- ^^^^^^^^^^^^^^^^^ Use `compact_blank!` instead.
86
- RUBY
87
-
88
- expect_correction ( <<~RUBY )
89
- collection.compact_blank!
90
- RUBY
91
- end
92
-
93
- it 'registers and corrects an offense when using `reject { |k, v| v.empty? }`' do
94
- expect_offense ( <<~RUBY )
95
- collection.reject { |k, v| v.empty? }
96
- ^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `compact_blank` instead.
97
- RUBY
98
-
99
- expect_correction ( <<~RUBY )
100
- collection.compact_blank
101
- RUBY
102
- end
103
-
104
49
it 'does not register an offense when using `compact_blank`' do
105
50
expect_no_offenses ( <<~RUBY )
106
51
collection.compact_blank
113
58
RUBY
114
59
end
115
60
116
- it 'does not register an offense when using `reject { |k, v| k.empty ? }`' do
61
+ it 'does not register an offense when using `reject { |k, v| k.blank ? }`' do
117
62
expect_no_offenses ( <<~RUBY )
118
- collection.reject { |k, v| k.empty ? }
63
+ collection.reject { |k, v| k.blank ? }
119
64
RUBY
120
65
end
121
66
@@ -126,6 +71,12 @@ def foo(arg)
126
71
end
127
72
RUBY
128
73
end
74
+
75
+ it 'does not register an offense when using `reject { |e| e.empty? }`' do
76
+ expect_no_offenses ( <<~RUBY )
77
+ collection.reject { |e| e.empty? }
78
+ RUBY
79
+ end
129
80
end
130
81
131
82
context 'Rails <= 6.0' , :rails60 do
0 commit comments