Skip to content

Commit a15f582

Browse files
committed
README: Recommend using Regexp filters for add_group
Using String filters can include wrong files to groups because it matches if the string is contained within the path. For example: # This matches files like `./lib/foo.rb` # but also `./app/models/library.rb' add_group 'Libraries', 'lib' # Prefer Regexp filter instead: add_group 'Libraries', %r{^/lib/}
1 parent ce45fa6 commit a15f582

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ Add your groups with:
489489

490490
```ruby
491491
SimpleCov.start do
492-
add_group "Models", "app/models"
493-
add_group "Controllers", "app/controllers"
492+
add_group "Models", %r{^/app/models}
493+
add_group "Controllers", %r{^/app/controllers}
494494
add_group "Long files" do |src_file|
495495
src_file.lines.count > 100
496496
end
497-
add_group "Multiple Files", ["app/models", "app/controllers"] # You can also pass in an array
497+
add_group "Multiple Files", [%r{^/app/models}, %r{^/app/controllers}] # You can also pass in an array
498498
add_group "Short files", LineFilter.new(5) # Using the LineFilter class defined in Filters section above
499499
end
500500
```
@@ -738,10 +738,10 @@ SimpleCov.profiles.define 'rails' do
738738
add_filter '/test/'
739739
add_filter '/config/'
740740

741-
add_group 'Controllers', 'app/controllers'
742-
add_group 'Models', 'app/models'
743-
add_group 'Helpers', 'app/helpers'
744-
add_group 'Libraries', 'lib'
741+
add_group 'Controllers', %r{^/app/controllers}
742+
add_group 'Models', %r{^/app/models}
743+
add_group 'Helpers', %r{^/app/helpers}
744+
add_group 'Libraries', %r{^/lib/}
745745
end
746746
```
747747

0 commit comments

Comments
 (0)