Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop handling string filters as regexps #616

Conversation

yujinakayama
Copy link
Contributor

@yujinakayama yujinakayama commented Aug 27, 2017

Previously, filter strings passed to add_filter have been handled as regexps. It means, for example, add_filter '.pl' matches against sample.rb because . is handled as any character in regexp.

As now we have regexp filter, there's no reason to handle filter strings as regexps.

However we need to think about semver with this change. If this behavior was intentional, we cannot introduce this change until next major version bump. Or we can do if this was a bug.

What do you think?

Previously, filter strings passed to `add_filter` have been handled as regexps.
It means, for example, `add_filter '.pl'` matches against 'sample.rb'
because `.` is handled as _any character_ in regexp.

As now we have [regexp filter](simplecov-ruby#589),
there's no reason to handle filter strings as regexps.

However we need to think about semver with this change.
If this behavior was intentional,
we cannot introduce this change until next major version bump.
Or we can do if this was a _bug_.
@PragTob
Copy link
Collaborator

PragTob commented Aug 28, 2017

👋

Hi, first thanks for your contribution 🎉

This is an interesting issue and a very astute observation! A problem is that for all that I can tell it has been behaving like this forever.

However, the README doesn't seem to mention that it has regexp like behaviour:

All in all, I'm in favor, the example you provided is especially frightening 😱 So thanks for that!

There's another issue I might need to reach out to Christoph for, just wanna double check with him as I'm not aware of all the history/intentions.

Regarding version, in 0.y.z versions you don't need a major version bump for changes:

Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.

If we fix it I'd internally classify it as a "bug" but as it breaks behaviour old as time I'd still bump a minor to release it so people can have a proper warning looking at the changelog because patch level updates (imo even in 0.y.z) should be safe.

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Issue is more the if/when/what as explained in the previous comment :)

it "doesn't match a parent directory with a new SimpleCov::StringFilter" do
parent_dir_name = File.basename(File.expand_path("..", File.dirname(__FILE__)))
expect(SimpleCov::StringFilter.new(parent_dir_name)).not_to be_matches subject
end

it "matches a new SimpleCov::StringFilter '/fixtures/'" do
expect(SimpleCov::StringFilter.new("sample.rb")).to be_matches subject
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why id you remove this spec, shouldn't that still work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, missed that! Seems like it was meant to be "/fixtures/" indeed! Unless I missed that one as well :)

@yujinakayama
Copy link
Contributor Author

If we fix it I'd internally classify it as a "bug" but as it breaks behaviour old as time I'd still bump a minor to release it so people can have a proper warning looking at the changelog because patch level updates (imo even in 0.y.z) should be safe.

I forgot the fact that simplecov is still under 1.0 👍

@colszowka
Copy link
Collaborator

Hey all, sorry for my late reply! Thanks for the PR, looks very reasonable to me!

As to the potentially breaking change:

Personally, I'd say I originally built it like this out of shear laziness. I agree that it should not automatically expand into a regexp under the hood and magically. I also agree that this could be a breaking change for existing users, since a significant behaviour changes. Under SemVer that should warrant a major version bump. We really should finally declare something 1.0 😁 I think what @PragTob suggested, to bump minor version should be fine 🚀

@PragTob
Copy link
Collaborator

PragTob commented Oct 21, 2017

Well then :shipit:

Thanks @colszowka

@PragTob PragTob merged commit e1fc172 into simplecov-ruby:master Oct 21, 2017
PragTob added a commit that referenced this pull request Oct 21, 2017
[ci skip]
@yujinakayama yujinakayama deleted the stop-handling-filter-string-as-regexp branch December 4, 2017 06:21
This was referenced Mar 19, 2018
nevinera added a commit to nevinera/rspec-core that referenced this pull request May 9, 2024
The filter for spec/ was actually matching basically everything in the
gem (and discarding it), because it's all in lib/rspec/, and simplecov
is doing a string-based infix match. I'm not certain when that changed,
but my guess is 2018, in this PR:

    simplecov-ruby/simplecov#616

I also adjusted the minimum_coverage down to 99, since we're currently
at 99.26, and not 100%. I'll get on that shortly.
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.

3 participants