Fix NoMethodError in formatters= for non-Array arguments#1224
Open
koic wants to merge 1 commit into
Open
Conversation
simplecov 1.0.0 broke a formatter configuration pattern the README documented for years: ```ruby SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::JSONFormatter, ]) ``` `MultiFormatter.new` returns a `Class`, not an `Array`, so the 1.0.0 setter raised `NoMethodError` on `formatters.empty?`. Up to 0.22.x the setter handed the value straight to `MultiFormatter.new`, whose internal `Array()` call normalized single formatters transparently. This surfaced in ruby/ruby CI, where net-imap's test helper still uses the pattern above: https://github.com/ruby/ruby/actions/runs/29193505325/job/86652245625?pr=17830 Restore the 0.22.x tolerance by normalizing the setter input with `Array()`. As a side effect `formatters = nil` now opts out of formatting, consistent with the `formatter false` / `formatters []` opt-out semantics introduced in 1.0.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
simplecov 1.0.0 broke a formatter configuration pattern the README documented for years:
MultiFormatter.newreturns aClass, not anArray, so the 1.0.0 setter raisedNoMethodErroronformatters.empty?. Up to 0.22.x the setter handed the value straight toMultiFormatter.new, whose internalArray()call normalized single formatters transparently.This surfaced in ruby/ruby CI, where net-imap's test helper still uses the pattern above: https://github.com/ruby/ruby/actions/runs/29193505325/job/86652245625?pr=17830
Restore the 0.22.x tolerance by normalizing the setter input with
Array(). As a side effectformatters = nilnow opts out of formatting, consistent with theformatter false/formatters []opt-out semantics introduced in 1.0.0.