Skip to content

prefer_key_path in 0.58.0 warns if {$0} instead of (\.self) for SwiftPM using Swift 5 #5965

@rgoldberg

Description

@rgoldberg

New Issue Checklist

Bug Description

prefer_key_path in 0.58.0 warns if {$0} is used instead of ()\.self for a Swift file in a SwiftPM project whose Package.swift contains // swift-tools-version:5.7.1 & swiftLanguageVersions: [.v5].

I assume that SwiftVersion.current used in SwiftVersion.current >= .six doesn't properly determine the correct version of Swift that is being used.

Mention the command or other SwiftLint integration method that caused the issue. Include stack traces or command output.

$ swiftlint --strict --quiet Sources

Environment

  • SwiftLint version (run swiftlint version to be sure) 0.58.0
  • Xcode version (run xcodebuild -version to be sure) 16.0 (16A242d)
  • Installation method used (Homebrew, CocoaPods, building from source, etc) Homebrew
  • Configuration file:
---
opt_in_rules:
  - all
disabled_rules:
  # eventually enable
  - file_header
  - one_declaration_per_file
  - trailing_comma
  # never enable
  - contrasted_opening_brace
  - explicit_acl
  - explicit_enum_raw_value
  - explicit_top_level_acl
  - explicit_type_interface
  - no_extension_access_modifier
  - no_grouping_extension
  - no_magic_numbers
  - prefixed_toplevel_constant
  - sorted_enum_cases
  - vertical_whitespace_between_cases
file_name:
  excluded: [Finder.swift, Utilities.swift]
file_types_order:
  order:
    [
      [main_type],
      [supporting_type],
      [extension],
      [preview_provider],
      [library_content_provider],
    ]
number_separator:
  minimum_length: 6
type_contents_order:
  order:
    [
      [case],
      [type_alias, associated_type],
      [subtype],
      [type_property],
      [instance_property],
      [ib_inspectable],
      [ib_outlet],
      [initializer],
      [deinitializer],
      [type_method],
      [view_life_cycle_method],
      [ib_action],
      [other_method],
      [subscript],
    ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIdeas for improvements of existing features and rules.helpQuestions or user problems that require more explanation rather than code changes.integrationIssues related to integration of SwiftLint into toolchains.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions