rubocop-performance
rubocop-performance copied to clipboard
Disable Performance/OpenStruct for Rubies >= 2.1
Is your feature request related to a problem? Please describe.
rubocop-performance
told me to avoid instantiating OpenStructs because it invalidates the Ruby global method cache. But I recall Ruby changed the way it cached methods a while ago.
I am fairly confident that the claim:
Instantiation of an
OpenStruct
invalidates Ruby global method cache
has been untrue since Ruby 2.1.
references:
That change was merged in 2013 and almost certainly released with Ruby 2.1 in December 2013.
See also this tweet from Nate Berkopec:
TIL openstruct does not invalidate the global method cache in Ruby 2.1+ #rubyconf
https://twitter.com/nateberkopec/status/796743575392440320
Describe the solution you'd like
We can probably look at the TargetRubyVersion
and only check the older Rubies.