From 4f8912e28356ecb0a07f8f8fce0d60b22960f335 Mon Sep 17 00:00:00 2001 From: Sergey Pekar Date: Fri, 30 May 2025 21:43:49 +0200 Subject: [PATCH] Update non_optional_string_data_conversion rule docs to make it more clear --- .../Lint/NonOptionalStringDataConversionRule.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/SwiftLintBuiltInRules/Rules/Lint/NonOptionalStringDataConversionRule.swift b/Source/SwiftLintBuiltInRules/Rules/Lint/NonOptionalStringDataConversionRule.swift index 5141717370..c0c816e8f3 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Lint/NonOptionalStringDataConversionRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Lint/NonOptionalStringDataConversionRule.swift @@ -5,14 +5,16 @@ struct NonOptionalStringDataConversionRule: Rule { var configuration = SeverityConfiguration(.warning) static let description = RuleDescription( identifier: "non_optional_string_data_conversion", - 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:)`)", kind: .lint, nonTriggeringExamples: [ - Example("Data(\"foo\".utf8)") + Example("Data(\"foo\".utf8)"), + Example("String(decoding: data, as: UTF8.self)"), ], triggeringExamples: [ - Example("\"foo\".data(using: .utf8)") + Example("\"foo\".data(using: .utf8)"), + Example("String(data: data, encoding: .utf8)"), ] ) }