@@ -133,11 +133,17 @@ def method
133
133
end
134
134
135
135
it "handles different locations properly" do
136
- RuboCop ::Cop ::Team . any_instance . expects ( :inspect_file ) . returns ( [ OpenStruct . new (
137
- location : RuboCop ::Cop ::Lint ::Syntax ::PseudoSourceRange . new ( 1 , 0 , "" ) ,
138
- cop_name : "fake" ,
139
- message : "message"
140
- ) ] )
136
+ RuboCop ::Cop ::Team . any_instance . expects ( :inspect_file ) . returns (
137
+ [
138
+ OpenStruct . new (
139
+ location : RuboCop ::Cop ::Lint ::Syntax ::PseudoSourceRange . new (
140
+ 1 , 0 , ""
141
+ ) ,
142
+ cop_name : "fake" ,
143
+ message : "message"
144
+ )
145
+ ]
146
+ )
141
147
create_source_file ( "my_script.rb" , <<-EORUBY )
142
148
#!/usr/bin/env ruby
143
149
@@ -154,8 +160,8 @@ def method
154
160
location = {
155
161
"path" => "my_script.rb" ,
156
162
"positions" => {
157
- "begin" => { "column" => 1 , "line" => 1 } ,
158
- "end" => { "column" => 1 , "line" => 1 }
163
+ "begin" => { "column" => 1 , "line" => 1 } ,
164
+ "end" => { "column" => 1 , "line" => 1 }
159
165
}
160
166
}
161
167
assert_equal location , result [ "location" ]
@@ -190,12 +196,14 @@ def method(a,b,c,d,e,f,g)
190
196
191
197
json = JSON . parse ( '[' + output . split ( "\u0000 " ) . join ( ',' ) + ']' )
192
198
193
- result = json . select { |i | i && i [ "check_name" ] =~ /Metrics\/ CyclomaticComplexity/ } . first
199
+ result = json . find do |i |
200
+ i && i [ "check_name" ] =~ %r{Metrics\/ CyclomaticComplexity}
201
+ end
194
202
location = {
195
203
"path" => "my_script" ,
196
204
"positions" => {
197
- "begin" => { "column" => 11 , "line" => 3 } ,
198
- "end" => { "column" => 14 , "line" => 21 }
205
+ "begin" => { "column" => 11 , "line" => 3 } ,
206
+ "end" => { "column" => 14 , "line" => 21 }
199
207
}
200
208
}
201
209
assert_equal location , result [ "location" ]
@@ -233,7 +241,7 @@ def method
233
241
end
234
242
EORUBY
235
243
output = run_engine (
236
- "include_paths" => %w( included_root_file.rb subdir/ )
244
+ "include_paths" => %w[ included_root_file.rb subdir/ ]
237
245
)
238
246
assert !includes_check? ( output , "Lint/UselessAssignment" )
239
247
assert !includes_check? ( output , "Style/AndOr" )
@@ -245,7 +253,7 @@ def method
245
253
output = run_engine (
246
254
"include_paths" => %w[ config.yml ]
247
255
)
248
- refute ( issues ( output ) . detect do |i |
256
+ refute ( issues ( output ) . detect do |i |
249
257
i [ "description" ] == "unexpected token tCOLON"
250
258
end )
251
259
end
@@ -258,12 +266,12 @@ def method
258
266
return false
259
267
end
260
268
EORUBY
261
- output = run_engine ( "include_paths" => %w( Rakefile ) )
269
+ output = run_engine ( "include_paths" => %w[ Rakefile ] )
262
270
assert includes_check? ( output , "Lint/UselessAssignment" )
263
271
end
264
272
265
273
def includes_check? ( output , cop_name )
266
- !! issues ( output ) . detect { |i | i [ "check_name" ] =~ /#{ cop_name } $/ }
274
+ issues ( output ) . any? { |i | i [ "check_name" ] =~ /#{ cop_name } $/ }
267
275
end
268
276
269
277
def includes_content_for? ( output , cop_name )
0 commit comments