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

Rule Request: explicit rawValue for camelCased Codable String enum #2888

Closed
2 tasks done
marcelofabri opened this issue Oct 1, 2019 · 1 comment
Closed
2 tasks done
Labels
rule-request Requests for a new rules.

Comments

@marcelofabri
Copy link
Collaborator

New Issue Checklist

New rule request

Please describe the rule idea, format
this issue's title as Rule Request: [Rule Name] and describe:

  1. Why should this rule be added? Share links to existing discussion about what
    the community thinks about this.

We use JSONDecoder.KeyDecodingStrategy.convertFromSnakeCase in our project. Our enums are mostly snake case on the backend too. Because of that, some people in our team had mistakenly assumed that these enum cases would also be converted from snake case (which is not true).

  1. Provide several examples of what would and wouldn't trigger violations.
enum Status: String, Codable {
   case ok // shouldn't trigger
   case notAcceptable // should trigger
   case maybeAcceptable = "maybe_acceptable" // shouldn't trigger
}

enum Status: String, Decodable {
   case ok // shouldn't trigger
   case notAcceptable // should trigger
   case maybeAcceptable = "maybe_acceptable" // shouldn't trigger
}

enum Status: String {
   case ok // shouldn't trigger
   case notAcceptable // shouldn't trigger
   case maybeAcceptable = "maybe_acceptable" // shouldn't trigger
}

enum Status: Int, Codable {
   case ok // shouldn't trigger
   case notAcceptable // shouldn't trigger
   case maybeAcceptable = -1 // shouldn't trigger
}
  1. Should the rule be configurable, if so what parameters should be configurable?

Just the severity.

  1. Should the rule be opt-in or enabled by default? Why?
    See README.md for guidelines on when to mark a rule as opt-in.

Opt-in, as this would only add noise in some projects

@marcelofabri marcelofabri added the rule-request Requests for a new rules. label Oct 1, 2019
fddecc added a commit to fddecc/SwiftLint that referenced this issue Oct 2, 2019
fddecc added a commit to fddecc/SwiftLint that referenced this issue Oct 2, 2019
marcelofabri pushed a commit to fddecc/SwiftLint that referenced this issue Oct 21, 2019
marcelofabri pushed a commit to fddecc/SwiftLint that referenced this issue Oct 21, 2019
marcelofabri added a commit that referenced this issue Oct 21, 2019
Add `raw_value_for_camel_cased_codable_enum` (#2888)
@marcelofabri
Copy link
Collaborator Author

Closed in #2889 💯

lechuckcaptain pushed a commit to lechuckcaptain/SwiftLint that referenced this issue Oct 25, 2019
lechuckcaptain pushed a commit to lechuckcaptain/SwiftLint that referenced this issue Oct 25, 2019
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

1 participant