-
Notifications
You must be signed in to change notification settings - Fork 6
[ECO-5356] Remove public raw values from enums. #316
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
base: main
Are you sure you want to change the base?
Conversation
""" WalkthroughThis change refactors several enums in the codebase to remove their direct conformance to Changes
Sequence Diagram(s)sequenceDiagram
participant Decoder
participant Message
participant MessageAction (enum)
participant InternalRawRepresentable
Decoder->>Message: decode(from: JSON)
Message->>Decoder: extract "action" as String
Message->>MessageAction: init?(rawValue: String)
alt valid action
MessageAction-->>Message: MessageAction instance
Message-->>Decoder: Message instance
else invalid action
Message-->>Decoder: throw DecodingError
end
Assessment against linked issues
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
3a6d7eb
to
939e576
Compare
extension MessageAction: InternalRawRepresentable { | ||
internal typealias RawValue = String | ||
|
||
internal init?(rawValue: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if we could avoid duplicating the raw values. There are various ways you could do this, but perhaps the easiest would be to just have an internal WireMessageAction: String
type that you convert to and from MessageAction
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -171,9 +171,13 @@ extension Message: JSONObjectDecodable { | |||
values: summaryJson | |||
) | |||
} | |||
let rawAction = try jsonObject.stringValueForKey("action") | |||
guard let action = MessageAction(rawValue: rawAction) else { | |||
throw JSONValueDecodingError.failedToDecodeFromRawValue(rawAction).toInternalError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also would be good to have a convenience method à la rawRepresentableValueForKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I've understood, this method belongs to jsonObject
and similar to stringValueForKey
?
939e576
to
1f07c14
Compare
1f07c14
to
8f6626a
Compare
Closes #279
Summary by CodeRabbit
Refactor
Bug Fixes