Skip to content

optional_data_string_conversion does not trigger when .init(decoding:as:) is called instead of String(decoding:as:) #6359

@vapidinfinity

Description

@vapidinfinity

New Issue Checklist

Bug Description

As the title suggests, optional_data_string_conversion does not trigger when calling String.init() instead of directly calling String().

Example:

// This triggers a violation:
let text = String(decoding: data, as: UTF8.self)

// This does not trigger a violation:
let text: String = .init(decoding: data, as: UTF8.self)

(swiftlint is in its default configuration, ran by xcode)

Environment

  • SwiftLint version — 0.62.2
  • Xcode version — 26.1 (17B55)
  • Installation method used (Homebrew, CocoaPods, building from source, etc)
  • Configuration file:
# n/a?

Are you using nested configurations? If so, paste their
relative paths and respective contents.
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIdeas for improvements of existing features and rules.good first issueIssue to be taken up by new contributors yet unfamiliar with the project.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions