Skip to content

Stop polluting ::Array and ::Hash - #449

Merged
colszowka merged 1 commit into
simplecov-ruby:masterfrom
amatsuda:🐵🔫
Jan 20, 2016

Hidden character warning

The head ref may contain hidden characters: "\ud83d\udc35\ud83d\udd2b"
Merged

colszowka merged 1 commit into
simplecov-ruby:masterfrom
amatsuda:🐵🔫

Conversation

@amatsuda

Copy link
Copy Markdown
Member

Requiring simlpecov globally adds the merge_resultset method to the built-in Array class and Hash class via monkey-patching, which means this gem widely changes the test subject's behavior.
Such a horrible vandalism should never be done by a test coverage measurement tool. We should immediately stop doing this.

I suppose the same merging logic could be more safely and cleanly implemented by two or three static methods instead of extending the core classes, but for now, I'd suggest a patch that changes the Result class to dynamically extend the result objects using the existing Modules.

This way we would be able to minimize the conflict with other PRs working on the merging_helpers e.g. #436 and #441.

@colszowka

Copy link
Copy Markdown
Collaborator

The build failed because of Rubycop, there is #448 for that.

@colszowka

Copy link
Copy Markdown
Collaborator

As to the actual topic: I totally agree with you, we must stop doing this, thanks for pointing it out!

We still need to remove the actual includes from the source https://github.com/colszowka/simplecov/blob/master/lib/simplecov/merge_helpers.rb#L37-L38 - would you mind doing this? I would expect that with the existing changes this should keep working?

@amatsuda

Copy link
Copy Markdown
Member Author

@colszowka

We still need to remove the actual includes from the source

I believe that was actually included in the previous commit, and at least the specs and features were passing locally with that changeset!

@colszowka

Copy link
Copy Markdown
Collaborator

I'm an incapable of reading diffs it seems. Thanks! Merging! I also created #450 for the followup work

colszowka added a commit that referenced this pull request Jan 20, 2016
Stop polluting ::Array and ::Hash
@colszowka
colszowka merged commit dd2f7c1 into simplecov-ruby:master Jan 20, 2016
@colszowka

Copy link
Copy Markdown
Collaborator

Lol, awesome branch naming 🐵 🔫

colszowka added a commit that referenced this pull request Jan 20, 2016
craiglittle pushed a commit to craiglittle/simplecov that referenced this pull request Feb 13, 2016
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Feb 17, 2016
## Enhancements

## Bugfixes

0.11.2 2016-02-03 ([changes](simplecov-ruby/simplecov@v0.11.1...v0.11.2))
=================

## Enhancements

* Do not globally pollute Array and Hash with `merge_resultset` utility methods. See [#449](simplecov-ruby/simplecov#449) (thanks @amatsuda)
* Do not `mkdir_p` the `coverage_path` on every access of the method (See [#453](simplecov-ruby/simplecov#453) (thanks @paddor)
* Fixes a Ruby warning related to the `track_files` configuration. See [#447](simplecov-ruby/simplecov#447) (thanks @craiglittle)
* Add a group for background jobs to default Rails profile. See [#442](simplecov-ruby/simplecov#442) (thanks @stve)

## Bugfixes

* Fix root_filter evaluates SimpleCov.root before initialization. See [#437](simplecov-ruby/simplecov#437) (thanks @tmtm)
@amatsuda
amatsuda deleted the 🐵🔫 branch April 7, 2016 23:52
msk pushed a commit to msk/pkgsrc that referenced this pull request May 11, 2026
## Enhancements

## Bugfixes

0.11.2 2016-02-03 ([changes](simplecov-ruby/simplecov@v0.11.1...v0.11.2))
=================

## Enhancements

* Do not globally pollute Array and Hash with `merge_resultset` utility methods. See [#449](simplecov-ruby/simplecov#449) (thanks @amatsuda)
* Do not `mkdir_p` the `coverage_path` on every access of the method (See [#453](simplecov-ruby/simplecov#453) (thanks @paddor)
* Fixes a Ruby warning related to the `track_files` configuration. See [#447](simplecov-ruby/simplecov#447) (thanks @craiglittle)
* Add a group for background jobs to default Rails profile. See [#442](simplecov-ruby/simplecov#442) (thanks @stve)

## Bugfixes

* Fix root_filter evaluates SimpleCov.root before initialization. See [#437](simplecov-ruby/simplecov#437) (thanks @tmtm)
jperkin pushed a commit to TritonDataCenter/pkgsrc that referenced this pull request May 14, 2026
## Enhancements

## Bugfixes

0.11.2 2016-02-03 ([changes](simplecov-ruby/simplecov@v0.11.1...v0.11.2))
=================

## Enhancements

* Do not globally pollute Array and Hash with `merge_resultset` utility methods. See [#449](simplecov-ruby/simplecov#449) (thanks @amatsuda)
* Do not `mkdir_p` the `coverage_path` on every access of the method (See [#453](simplecov-ruby/simplecov#453) (thanks @paddor)
* Fixes a Ruby warning related to the `track_files` configuration. See [#447](simplecov-ruby/simplecov#447) (thanks @craiglittle)
* Add a group for background jobs to default Rails profile. See [#442](simplecov-ruby/simplecov#442) (thanks @stve)

## Bugfixes

* Fix root_filter evaluates SimpleCov.root before initialization. See [#437](simplecov-ruby/simplecov#437) (thanks @tmtm)
tsutsui pushed a commit to tsutsui/pkgsrc that referenced this pull request Oct 17, 2026
## Enhancements

## Bugfixes

0.11.2 2016-02-03 ([changes](simplecov-ruby/simplecov@v0.11.1...v0.11.2))
=================

## Enhancements

* Do not globally pollute Array and Hash with `merge_resultset` utility methods. See [#449](simplecov-ruby/simplecov#449) (thanks @amatsuda)
* Do not `mkdir_p` the `coverage_path` on every access of the method (See [#453](simplecov-ruby/simplecov#453) (thanks @paddor)
* Fixes a Ruby warning related to the `track_files` configuration. See [#447](simplecov-ruby/simplecov#447) (thanks @craiglittle)
* Add a group for background jobs to default Rails profile. See [#442](simplecov-ruby/simplecov#442) (thanks @stve)

## Bugfixes

* Fix root_filter evaluates SimpleCov.root before initialization. See [#437](simplecov-ruby/simplecov#437) (thanks @tmtm)
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.

2 participants