Skip to content

README: Recommend using Regexp filters for add_group#1062

Closed
splattael wants to merge 1 commit intosimplecov-ruby:mainfrom
splattael:readme-add-group
Closed

README: Recommend using Regexp filters for add_group#1062
splattael wants to merge 1 commit intosimplecov-ruby:mainfrom
splattael:readme-add-group

Conversation

@splattael
Copy link
Copy Markdown
Contributor

@splattael splattael commented Jul 5, 2023

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/}

See also https://gitlab.com/gitlab-org/gitlab/-/issues/416910

Alternative

Instead, we could adjust the String filter to use start_with? instead of include? but that'd be a breaking change and also require users to prepend a leading slash to their configuration like:

  # Before
  add_group 'Libraries', 'lib'

  # After
  add_group 'Libraries', '/lib'

@splattael
Copy link
Copy Markdown
Contributor Author

This is somewhat related to #1016.

👋 @amatsuda If you have, do you mind reviewing this MR? 🙏

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/}
@sferik sferik force-pushed the main branch 2 times, most recently from 3422349 to 4f8fece Compare April 3, 2026 19:51
@sferik sferik closed this in cd95d62 Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant