Skip to content

Enable Style/MutableConstant cop with literals style#53

Draft
paracycle wants to merge 1 commit intomainfrom
uk-freeze-mutable-constant-literals
Draft

Enable Style/MutableConstant cop with literals style#53
paracycle wants to merge 1 commit intomainfrom
uk-freeze-mutable-constant-literals

Conversation

@paracycle
Copy link
Copy Markdown
Member

Ractor safety requires that for any class/module that can be shared between Ractors all of their constants are shareable as well. For simple constants that is trivially possible by freezing the constants at definition time, unless the constant is being used for a mutable context.

This PR enables the MutableConstant cop for literal constant assignments, which should mostly be static values for the lifetime of the framework. For the rare cases where constants are being used in order to be mutated (e.g. hashes used for caching, or constants defined for extension by framework consumers) have been turned into non-literal definitions.

Motivation / Background

This Pull Request has been created because [REPLACE ME]

Detail

This Pull Request changes [REPLACE ME]

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Ractor safety requires that for any class/module that can be shared
between Ractors all of their constants are shareable as well. For simple
constants that is trivially possible by freezing the constants at
definition time, unless the constant is being used for a mutable
context.

This PR enables the MutableConstant cop for literal constant
assignments, which should mostly be static values for the lifetime of
the framework. For the rare cases where constants are being used for
mutation (e.g. hashes used for caching, or constants defined for
extension by framework consumers) have been marked with a
`rubocop:disable` comment, until we have better fixes for them.
@paracycle paracycle force-pushed the uk-freeze-mutable-constant-literals branch from 1e51435 to 5700c17 Compare May 9, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant