-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Update non_optional_string_data_conversion rule docs and examples to make it more clear #6088
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
Here's an example of your CHANGELOG entry: * Update non_optional_string_data_conversion rule docs and examples to make it more clear.
[SergeyPekar](https://github.com/SergeyPekar)
[#issue_number](https://github.com/realm/SwiftLint/issues/issue_number) note: There are two invisible spaces after the entry's text. Generated by 🚫 Danger |
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 for the contribution!
However, this rule doesn't actually work in both directions. There are optional_data_string_conversion
and non_optional_string_data_conversion
which separate both cases from each other.
name: "Non-optional String -> Data Conversion", | ||
description: "Prefer non-optional `Data(_:)` initializer when converting `String` to `Data`", | ||
name: "Non-optional String <-> Data Conversion", | ||
description: "Prefer the non-optional initializers when converting between `String` and `Data` (e.g. `Data(_:)` and `String(decoding:as:)`)", |
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.
If you are still interested in providing extended documentation for this rule, please let the description
property as it is and prefer the optional rationale
property. It serves exactly this purpose.
@SergeyPekar: Do you still fancy to add more documentation? If not, please close the PR at will. |
I will take a look during the week and close the PR if I won't come up with anything fancy |
Motivation:
The rule
non_optional_string_data_conversion
is bidirectional it is triggered when converting string to data as well as when converting from data to string so this behaviour is needed to be clearly documented.Changes: