Update non_optional_string_data_conversion rule docs and examples to make it more clear#6088
Update non_optional_string_data_conversion rule docs and examples to make it more clear#6088SergeyPekar wants to merge 1 commit intorealm:mainfrom
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 |
SimplyDanny
left a comment
There was a problem hiding this comment.
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.
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_conversionis 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: