File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,9 +74,9 @@ def coverage_for(path)
7474 source_file_for ( path ) &.coverage_statistics
7575 end
7676
77- # Returns a Hash of groups for this result. Define groups using SimpleCov.add_group 'Models', 'app/models'
77+ # Returns a Hash of groups for this result. Define groups using SimpleCov.group 'Models', 'app/models'
7878 def groups
79- @groups ||= apply_groups
79+ @groups ||= SimpleCov . grouped ( files , groups : @groups_config )
8080 end
8181
8282 # Applies the configured SimpleCov.formatter on this result. Returns
@@ -154,22 +154,5 @@ def apply_cover_filters!(cover_filters)
154154 @files . select { |source_file | cover_filters . any? { |filter | filter . matches? ( source_file ) } }
155155 )
156156 end
157-
158- # Build the per-group FileLists from `@groups_config`, plus the
159- # implicit "Ungrouped" bucket for files that no group filter
160- # matched.
161- def apply_groups
162- return { } if @groups_config . empty?
163-
164- grouped = @groups_config . transform_values do |filter |
165- SimpleCov ::FileList . new ( files . select { |source_file | filter . matches? ( source_file ) } )
166- end
167-
168- in_group = grouped . values . flat_map ( &:to_a )
169- ungrouped = files . reject { |source_file | in_group . include? ( source_file ) }
170- grouped [ "Ungrouped" ] = SimpleCov ::FileList . new ( ungrouped ) if ungrouped . any?
171-
172- grouped
173- end
174157 end
175158end
Original file line number Diff line number Diff line change @@ -59,8 +59,12 @@ def filtered(files)
5959 SimpleCov ::FileList . new result
6060 end
6161
62- # Applies the configured groups to the given array of SimpleCov::SourceFile items
63- def grouped ( files )
62+ # Bin the given source files by group filter. `groups:` defaults to
63+ # `SimpleCov.groups`; pass a Hash explicitly to bin against a
64+ # different group config (e.g., the snapshot a Result captured at
65+ # construction). Files matched by no group fall into the implicit
66+ # "Ungrouped" bucket.
67+ def grouped ( files , groups : SimpleCov . groups )
6468 return { } if groups . empty?
6569
6670 grouped = groups . transform_values do |filter |
You can’t perform that action at this time.
0 commit comments