File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,10 +62,6 @@ Lint/Void:
6262 Exclude :
6363 - " spec/fixtures/html_formatter/**/*"
6464
65- Metrics/AbcSize :
66- Description : Checks that the ABC size of methods is not higher than the configured maximum.
67- Max : 25 # TODO: Lower to 15
68-
6965Metrics/BlockLength :
7066 Description : Checks if the length of a block exceeds some maximum value.
7167 Exclude :
Original file line number Diff line number Diff line change @@ -153,15 +153,16 @@ def filtered(files)
153153 # Applies the configured groups to the given array of SimpleCov::SourceFile items
154154 #
155155 def grouped ( files )
156- grouped = { }
157- grouped_files = [ ]
158- groups . each do |name , filter |
159- grouped [ name ] = SimpleCov ::FileList . new ( files . select { |source_file | filter . matches? ( source_file ) } )
160- grouped_files += grouped [ name ]
161- end
162- if !groups . empty? && !( other_files = files . reject { |source_file | grouped_files . include? ( source_file ) } ) . empty?
163- grouped [ "Ungrouped" ] = SimpleCov ::FileList . new ( other_files )
156+ return { } if groups . empty?
157+
158+ grouped = groups . transform_values do |filter |
159+ SimpleCov ::FileList . new ( files . select { |source_file | filter . matches? ( source_file ) } )
164160 end
161+
162+ in_group = grouped . values . flat_map ( &:to_a )
163+ ungrouped = files . reject { |source_file | in_group . include? ( source_file ) }
164+ grouped [ "Ungrouped" ] = SimpleCov ::FileList . new ( ungrouped ) if ungrouped . any?
165+
165166 grouped
166167 end
167168
Original file line number Diff line number Diff line change @@ -284,15 +284,18 @@ def build_lines
284284 end
285285
286286 def process_skipped_lines ( lines )
287- # the array the lines are kept in is 0-based whereas the line numbers in the nocov
288- # chunks are 1-based and are expected to be like this in other parts (and it's also
289- # arguably more understandable)
290- no_cov_chunks . each { |chunk | lines [ ( chunk . begin - 1 ) ..( chunk . end - 1 ) ] . each ( &:skipped! ) }
291- directive_chunks . fetch ( :line ) . each { |chunk | lines [ ( chunk . begin - 1 ) ..( chunk . end - 1 ) ] . each ( &:skipped! ) }
292-
287+ mark_chunks_skipped ( lines , no_cov_chunks )
288+ mark_chunks_skipped ( lines , directive_chunks . fetch ( :line ) )
293289 lines
294290 end
295291
292+ # The array the lines are kept in is 0-based whereas the line numbers
293+ # in the chunks are 1-based (more understandable elsewhere), so each
294+ # range needs to be shifted down by one to slice into `lines`.
295+ def mark_chunks_skipped ( lines , chunks )
296+ chunks . each { |chunk | lines [ ( chunk . begin - 1 ) ..( chunk . end - 1 ) ] . each ( &:skipped! ) }
297+ end
298+
296299 def lines_strength
297300 lines . sum { |line | line . coverage . to_i }
298301 end
Original file line number Diff line number Diff line change @@ -71,13 +71,15 @@ def empty_statistics
7171 end
7272
7373 def expect_all_empty ( statistics )
74- expect ( statistics . covered ) . to eq 0
75- expect ( statistics . missed ) . to eq 0
76- expect ( statistics . omitted ) . to eq 0
77-
78- expect ( statistics . total ) . to eq 0
79- # might be counter-intuitive but think of it as "we covered everything we could"
80- expect ( statistics . percent ) . to eq 100.0
81- expect ( statistics . strength ) . to eq 0.0
74+ # 100% / 0.0 strength might be counter-intuitive but think of it as "we
75+ # covered everything we could".
76+ expect ( statistics ) . to have_attributes (
77+ covered : 0 ,
78+ missed : 0 ,
79+ omitted : 0 ,
80+ total : 0 ,
81+ percent : 100.0 ,
82+ strength : 0.0
83+ )
8284 end
8385end
You can’t perform that action at this time.
0 commit comments