|
24 | 24 | RUBY
|
25 | 25 | end
|
26 | 26 |
|
| 27 | + it 'registers and corrects an offense when using `reject { |k, v| v.blank? }`' do |
| 28 | + expect_offense(<<~RUBY) |
| 29 | + collection.reject { |k, v| v.blank? } |
| 30 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `compact_blank` instead. |
| 31 | + RUBY |
| 32 | + |
| 33 | + expect_correction(<<~RUBY) |
| 34 | + collection.compact_blank |
| 35 | + RUBY |
| 36 | + end |
| 37 | + |
27 | 38 | it 'registers and corrects an offense when using `delete_if { |e| e.blank? }`' do
|
28 | 39 | expect_offense(<<~RUBY)
|
29 | 40 | collection.delete_if { |e| e.blank? }
|
|
46 | 57 | RUBY
|
47 | 58 | end
|
48 | 59 |
|
| 60 | + it 'registers and corrects an offense when using `delete_if { |k, v| v.blank? }`' do |
| 61 | + expect_offense(<<~RUBY) |
| 62 | + collection.delete_if { |k, v| v.blank? } |
| 63 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `compact_blank!` instead. |
| 64 | + RUBY |
| 65 | + |
| 66 | + expect_correction(<<~RUBY) |
| 67 | + collection.compact_blank! |
| 68 | + RUBY |
| 69 | + end |
| 70 | + |
49 | 71 | it 'does not registers an offense when using `reject! { |e| e.blank? }`' do
|
50 | 72 | expect_no_offenses(<<~RUBY)
|
51 | 73 | collection.reject! { |e| e.blank? }
|
|
91 | 113 | RUBY
|
92 | 114 | end
|
93 | 115 |
|
| 116 | + it 'registers and corrects an offense when using `select { |k, v| v.present? }`' do |
| 117 | + expect_offense(<<~RUBY) |
| 118 | + collection.select { |k, v| v.present? } |
| 119 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `compact_blank` instead. |
| 120 | + RUBY |
| 121 | + |
| 122 | + expect_correction(<<~RUBY) |
| 123 | + collection.compact_blank |
| 124 | + RUBY |
| 125 | + end |
| 126 | + |
94 | 127 | it 'registers and corrects an offense when using `keep_if { |e| e.present? }`' do
|
95 | 128 | expect_offense(<<~RUBY)
|
96 | 129 | collection.keep_if { |e| e.present? }
|
|
113 | 146 | RUBY
|
114 | 147 | end
|
115 | 148 |
|
| 149 | + it 'registers and corrects an offense when using `keep_if { |k, v| v.present? }`' do |
| 150 | + expect_offense(<<~RUBY) |
| 151 | + collection.keep_if { |k, v| v.present? } |
| 152 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `compact_blank!` instead. |
| 153 | + RUBY |
| 154 | + |
| 155 | + expect_correction(<<~RUBY) |
| 156 | + collection.compact_blank! |
| 157 | + RUBY |
| 158 | + end |
| 159 | + |
116 | 160 | it 'does not register an offense when using `select! { |e| e.present? }`' do
|
117 | 161 | expect_no_offenses(<<~RUBY)
|
118 | 162 | collection.select! { |e| e.present? }
|
|
0 commit comments