Skip to content

Fix optional_data_string_conversion for String.init and .init - #6567

Closed
theamodhshetty wants to merge 1 commit into
realm:mainfrom
theamodhshetty:codex/fix-optional-data-string-conversion-init
Closed

theamodhshetty wants to merge 1 commit into
realm:mainfrom
theamodhshetty:codex/fix-optional-data-string-conversion-init

Conversation

@theamodhshetty

Copy link
Copy Markdown
Contributor

Summary

  • extend optional_data_string_conversion to catch String.init(decoding:as:)
  • catch contextual .init(decoding:as:) shorthand as the same String initializer form
  • add the changelog entry for the rule update

Why

The rule already flags String(decoding: data, as: UTF8.self), but the equivalent initializer spellings still slipped through. That left a real false-negative for codebases that prefer String.init(...) or contextual .init(...) when the result type is already known.

Validation

  • swift test --filter OptionalDataStringConversionRuleGeneratedTests
  • ./.build/debug/swiftlint lint Source/SwiftLintBuiltInRules/Rules/Lint/OptionalDataStringConversionRule.swift CHANGELOG.md --strict

@SwiftLintBot

Copy link
Copy Markdown
19 Messages
📖 Building this branch resulted in a binary size of 27384.21 KiB vs 27384.09 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.2 s vs 0.18 s on main (11% slower).
📖 Linting Alamofire with this PR took 0.2 s vs 0.22 s on main (9% faster).
📖 Linting Brave with this PR took 0.82 s vs 0.81 s on main (1% slower).
📖 Linting DuckDuckGo with this PR took 3.4 s vs 3.4 s on main (0% slower).
📖 Linting Firefox with this PR took 1.53 s vs 1.53 s on main (0% slower).
📖 Linting Kickstarter with this PR took 0.95 s vs 0.96 s on main (1% faster).
📖 Linting Moya with this PR took 0.15 s vs 0.12 s on main (25% slower).
📖 Linting NetNewsWire with this PR took 0.34 s vs 0.36 s on main (5% faster).
📖 Linting Nimble with this PR took 0.18 s vs 0.18 s on main (0% slower).
📖 Linting PocketCasts with this PR took 0.92 s vs 0.93 s on main (1% faster).
📖 Linting Quick with this PR took 0.13 s vs 0.14 s on main (7% faster).
📖 Linting Realm with this PR took 0.39 s vs 0.41 s on main (4% faster).
📖 Linting Sourcery with this PR took 0.31 s vs 0.32 s on main (3% faster).
📖 Linting Swift with this PR took 0.5 s vs 0.47 s on main (6% slower).
📖 Linting SwiftLintPerformanceTests with this PR took 3.84 s vs 3.87 s on main (0% faster).
📖 Linting VLC with this PR took 0.28 s vs 0.28 s on main (0% slower).
📖 Linting Wire with this PR took 2.0 s vs 2.0 s on main (0% slower).
📖 Linting WordPress with this PR took 1.37 s vs 1.35 s on main (1% slower).

Generated by 🚫 Danger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants