@@ -133,11 +133,17 @@ def method
133133 end
134134
135135 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+ )
141147 create_source_file ( "my_script.rb" , <<-EORUBY )
142148 #!/usr/bin/env ruby
143149
@@ -154,8 +160,8 @@ def method
154160 location = {
155161 "path" => "my_script.rb" ,
156162 "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 }
159165 }
160166 }
161167 assert_equal location , result [ "location" ]
@@ -190,12 +196,14 @@ def method(a,b,c,d,e,f,g)
190196
191197 json = JSON . parse ( '[' + output . split ( "\u0000 " ) . join ( ',' ) + ']' )
192198
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
194202 location = {
195203 "path" => "my_script" ,
196204 "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 }
199207 }
200208 }
201209 assert_equal location , result [ "location" ]
@@ -233,7 +241,7 @@ def method
233241 end
234242 EORUBY
235243 output = run_engine (
236- "include_paths" => %w( included_root_file.rb subdir/ )
244+ "include_paths" => %w[ included_root_file.rb subdir/ ]
237245 )
238246 assert !includes_check? ( output , "Lint/UselessAssignment" )
239247 assert !includes_check? ( output , "Style/AndOr" )
@@ -245,7 +253,7 @@ def method
245253 output = run_engine (
246254 "include_paths" => %w[ config.yml ]
247255 )
248- refute ( issues ( output ) . detect do |i |
256+ refute ( issues ( output ) . detect do |i |
249257 i [ "description" ] == "unexpected token tCOLON"
250258 end )
251259 end
@@ -258,12 +266,12 @@ def method
258266 return false
259267 end
260268 EORUBY
261- output = run_engine ( "include_paths" => %w( Rakefile ) )
269+ output = run_engine ( "include_paths" => %w[ Rakefile ] )
262270 assert includes_check? ( output , "Lint/UselessAssignment" )
263271 end
264272
265273 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 } $/ }
267275 end
268276
269277 def includes_content_for? ( output , cop_name )
0 commit comments