New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require raw values in enum #1778

Closed
jpsim opened this Issue Aug 15, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@jpsim
Collaborator

jpsim commented Aug 15, 2017

The opposite of our current rule that triggers a violation if the same string values as enum member names were used, resulting in redundant duplication, would sometimes be useful if you want to allow refactoring of the Swift API without breaking the API contract.

@jpsim jpsim added the rule-request label Aug 15, 2017

@marcelofabri

This comment has been minimized.

Show comment
Hide comment
@marcelofabri

marcelofabri Aug 17, 2017

Collaborator

This should be a good rule for someone wanting to begin contributing to SwiftLint. RedundantStringEnumValueRule can be used as an inspiration (but I'd expect this one to be actually simpler).

I also think this should be opt-in.

Collaborator

marcelofabri commented Aug 17, 2017

This should be a good rule for someone wanting to begin contributing to SwiftLint. RedundantStringEnumValueRule can be used as an inspiration (but I'd expect this one to be actually simpler).

I also think this should be opt-in.

@ornithocoder

This comment has been minimized.

Show comment
Hide comment
@ornithocoder

ornithocoder Aug 19, 2017

Contributor

There's also the Error case to think about.

enum FooError: Error {
    case expected(number: Int, got: Int)
}
Contributor

ornithocoder commented Aug 19, 2017

There's also the Error case to think about.

enum FooError: Error {
    case expected(number: Int, got: Int)
}

@marcelofabri marcelofabri changed the title from Require explicit associated values in enum to Require raw values in enum Aug 20, 2017

@jpsim

This comment has been minimized.

Show comment
Hide comment
@jpsim

jpsim Aug 21, 2017

Collaborator

Yes, definitely opt-in.

Collaborator

jpsim commented Aug 21, 2017

Yes, definitely opt-in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment