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

Add rule for redundant string enum values #946

Closed
jpsim opened this issue Dec 8, 2016 · 4 comments
Closed

Add rule for redundant string enum values #946

jpsim opened this issue Dec 8, 2016 · 4 comments
Labels
rule-request Requests for a new rules.

Comments

@jpsim
Copy link
Collaborator

jpsim commented Dec 8, 2016

enum Numbers: String {
    case one = "one"
    case two = "two"
    case three = "three"
}

is redundant. Could be simply

enum Numbers: String {
    case one
    case two
    case three
}
@jpsim jpsim added the rule-request Requests for a new rules. label Dec 8, 2016
@marcelofabri
Copy link
Collaborator

Should we handle Int enums as well? 🤔

@jpsim
Copy link
Collaborator Author

jpsim commented Dec 8, 2016

Maybe. That's not as clear to me.

@marcelofabri
Copy link
Collaborator

I'm implementing this and I'm uncertain if we should trigger only if all cases are redundant or if just one case (one violation per case).

This would trigger with the second approach, but not with the first:

private enum ConfigurationKey: String {
    case disabledRules = "disabled_rules"
    case enabledRules = "enabled_rules" // deprecated in favor of OptInRules
    case excluded = "excluded"
    case included = "included"
    case optInRules = "opt_in_rules"
    case reporter = "reporter"
    case useNestedConfigs = "use_nested_configs" // deprecated
    case whitelistRules = "whitelist_rules"
    case warningThreshold = "warning_threshold"
}

@jpsim
Copy link
Collaborator Author

jpsim commented Dec 8, 2016

This should trigger only if all cases are redundant.

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

2 participants