Skip to content

Fix #stats to prevent double formatting and use proper percent literal#52

Open
rmm5t wants to merge 1 commit intoigrigorik:masterfrom
rmm5t:rmm/fix-stats
Open

Fix #stats to prevent double formatting and use proper percent literal#52
rmm5t wants to merge 1 commit intoigrigorik:masterfrom
rmm5t:rmm/fix-stats

Conversation

@rmm5t
Copy link
Copy Markdown

@rmm5t rmm5t commented Apr 1, 2026

What does it do?

  • Fix #stats to prevent double formatting and use proper percent literal

What else do you need to know?

Note

  1. Ruby 4 is not as forgiving as Ruby 3 when trying to print a percent literal.
  2. The printf combined with the % operator was double formatting the string.

On Ruby 4.0, the spec suite failed with:

Failures:

  1) BloomFilter::CountingRedis a default CountingRedis instance should output current stats
     Failure/Error: expect { subject.stats }.not_to raise_error
     
       expected no Exception, got #<ArgumentError: malformed format string> with backtrace:
         # ./lib/bloomfilter/filter.rb:10:in 'String#%'
         # ./lib/bloomfilter/filter.rb:10:in 'BloomFilter::Filter#stats'
         # ./spec/counting_redis_spec.rb:44:in 'block (4 levels) in <top (required)>'
         # ./spec/counting_redis_spec.rb:44:in 'block (3 levels) in <top (required)>'
     # ./spec/counting_redis_spec.rb:44:in 'block (3 levels) in <top (required)>'

Issues

Fixes #53

Broken Screenshots

CleanShot 2026-04-01 at 08 49 10@2x CleanShot 2026-04-01 at 08 46 23@2x

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.

Filter#stats errors on Ruby 4.0

1 participant