standardrb/standard

Should we support the `Style/OpenStructUse`?

Closed this issue · 3 comments

OpenStruct seem to have a lot of caveats: https://ruby-doc.org/3.3.4/stdlibs/ostruct/OpenStruct.html#class-OpenStruct-label-Caveats which can effect performance and be a security concern. Any reason why we shouldn't turn this rule on?

This is a great question and one wonders—given how a combination of language features and improvements to Struct itself have made OpenStruct sort of redundant–whether it's on track to be deprecated.

In general, Standard is very hesitant to tell people what APIs to use unless there is a compelling performance concern, and we route all of those through rubocop-performance. I think I might be amenable if that case is strong enough? Curious what @tenderlove thinks on that one. @camilopayan?

People shouldn't use OpenStruct (IMO), but I don't think that's Standard's call to make. My impression was that Standard's domain is to be opinionated about code formatting only (where "formatting" includes bubbling up syntax errors because code with syntax errors can't be well formatted, by definition), so I don't think warning about OpenStruct belongs.

Yeah, I agree. Closing based on the theory that we generally don't tell people which APIs to use