-
Notifications
You must be signed in to change notification settings - Fork 326
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
Clarify Rule: Use Swift's automatic enum values unless they map to an external source. #216
Conversation
… external source.
README.md
Outdated
@@ -1804,10 +1804,12 @@ _You can enable the following settings in Xcode by running [this script](resourc | |||
|
|||
```swift | |||
// WRONG | |||
// swiftformat:disable redundantRawValues |
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.
Why is this "wrong"?
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.
@calda Are we talking "wrong" as comment "// WRONG"?
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.
Yeah
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 understand why this needs both // WRONG
and // swiftformat:disable redundantRawValues
. Doesn't the SwiftFormat directive mean this is correct (e.g. we're manually indicating that these values should be preserved because they map to an external source)?
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.
It was there even before I requested PR #216 and PR #215 . And, I thought it was there as it was not relying on Swift's automatic enum values. (Error could be coming from internal source.)
If you think otherwise then shouldn't line 1807 to 1812 (enum ErrorType) switched with 1841 to 1845 (enum ErrorType)?
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 understand why this needs both
// WRONG
and// swiftformat:disable redundantRawValues
. Doesn't the SwiftFormat directive mean this is correct (e.g. we're manually indicating that these values should be preserved because they map to an external source)?
Oh, sorry I saw this after commenting as I was writing a comment when you posted yours.
I thought we were agreed to state it as wrong and make exception to show example of wrongdoings. Here is our previous chat.
Sorry, if I misunderstood your intention, in this case would it be better to just delete // swiftformat:disable redundantRawValues
?
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.
haha yeah I think removing the directive is fine, otherwise this may be confusing
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.
@calda Thank you for sharing your thoughts. Fixed it accordingly!
@@ -1854,7 +1856,6 @@ _You can enable the following settings in Xcode by running [this script](resourc | |||
|
|||
// RIGHT | |||
// Relying on Swift's automatic enum values | |||
// swiftformat:disable redundantRawValues |
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.
Thanks 👍🏻
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.
🙂
… external source.
Summary
This PR fixes placement of
swiftformat:disable redundantRawValues
andswiftformat:enable redundantRawValues
.Reasoning
As discussed here, enum
ErrorType: String' in WRONG is the one that needs to be implemented with
swiftformat:disable redundantRawValuesand
swiftformat:enable redundantRawValues` as it needs to be excepted from swiftformat rules.And,
enum Planet: Int
needs to be reverted as before, because it is straightly following Swift's automatic enum values, and it does not contain any redundant raw values.Please react with 👍/👎 if you agree or disagree with this proposal.