rubocop / rubocop/ruby-style-guide
`extend`ing objects at runtime
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 16.5k
- Forks
- 3.3k
- PR merge metrics
- No merged PRs in 30d
Description
I've always avoided extending objects at runtime, like in this example:
class Polymorphic
def initialize(style: :foo)
extend Something if style == :bar
# ...
end
end
It used to be that performance could be severely impacted but it's not clear it's still the case today (see https://github.com/rubocop-hq/rubocop/pull/8881 )
Style-wise, it seems to complicate things and make introspection / debugging / branch-covering more difficult.
Is that an accepted principle to avoid this (and if so, is it still valid)?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the runtime extend example and the linked RuboCop pull request #8881 to establish whether the performance concern still applies. Then determine whether the style guide should state a principle about avoiding runtime extension and what wording would resolve the open question; done means a documented, agreed-upon guideline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100