Skip to content

Conversation

egiurleo
Copy link
Contributor

Related to #219.

This cop ensures that all T::Enums have at least two values to limit unnecessary uses of T::Enum.

@egiurleo egiurleo force-pushed the emily/multi-t-enum-values branch from 012b6b0 to 3805c79 Compare April 15, 2024 15:07
@egiurleo egiurleo marked this pull request as ready for review April 15, 2024 16:12
@egiurleo egiurleo requested a review from a team as a code owner April 15, 2024 16:12
@egiurleo egiurleo requested review from KaanOzkan and vinistock April 15, 2024 16:12
Comment on lines 44 to 50
def after_class(node)
@scopes.pop if t_enum?(node)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which case does this cover?

Copy link
Contributor Author

@egiurleo egiurleo Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This covers the case where two T::Enum classes are nested together. It's not a pattern I've seen, but it is technically possible.

Example:

class Enum1 < T::Enum        # @scopes = [Enum1]
   class Enum2 < T::Enum     # @scopes = [Enum1, Enum2]
      ...
   end                       # @scopes = [Enum1]
end                          # @scopes = []

@egiurleo egiurleo force-pushed the emily/multi-t-enum-values branch 2 times, most recently from 86a7724 to f01193b Compare April 15, 2024 21:25
egiurleo and others added 2 commits April 16, 2024 09:25
This cop ensures that all `T::Enum`s have at least two values to limit unnecessary uses of `T::Enum`.

Co-authored-by: Stan Lo <stan.lo@shopify.com>
@egiurleo egiurleo force-pushed the emily/multi-t-enum-values branch from f01193b to 24c7e88 Compare April 16, 2024 14:26
@egiurleo egiurleo merged commit 9471d9b into main Apr 16, 2024
@egiurleo egiurleo deleted the emily/multi-t-enum-values branch April 16, 2024 16:39
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.

3 participants