Skip to content
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
Closed

Require raw values in enum #1778

jpsim opened this issue Aug 15, 2017 · 3 comments
Labels
rule-request Requests for a new rules.

Comments

@jpsim
Copy link
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 Requests for a new rules. label Aug 15, 2017
@marcelofabri
Copy link
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.

@ornithocoder
Copy link
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 Require explicit associated values in enum Require raw values in enum Aug 20, 2017
@jpsim
Copy link
Collaborator Author

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
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

No branches or pull requests

3 participants