realm / SwiftLint

A tool to enforce Swift style and conventions.

Home Page:https://realm.github.io/SwiftLint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implicit Getter Violation false positive Xcode 15.3, Swift 5.10

sky-tiagoornelas opened this issue · comments

New Issue Checklist

Describe the bug

When updating Xcode to 15.3 (and consequently Swift 5.10), my project started triggering false positives for the implicit_getter rule in all my get {} set{} variables. Example:

Screenshot 2024-03-06 at 15 42 22

Environment

included: # paths to include during linting. `--path` is ignored if present.
  - **Redacted**
  - **Redacted**
  - **Redacted**
  - Components
  - Modules

excluded: # paths to ignore during linting. Takes precedence over `included`.
  - External

disabled_rules: # rule identifiers to exclude from running
  - line_length
  - todo
  - xctfail_message
  - identifier_name
  - unused_setter_value
  - orphaned_doc_comment
  - empty_enum_arguments
  - comment_spacing
  - unused_closure_parameter
  - inclusive_language
  - trailing_semicolon
  
opt_in_rules: # some rules are only opt-in
 - attributes
 - closure_end_indentation
 - closure_spacing
 - empty_count
 - explicit_init
 - fatal_error_message
 - file_header
 - first_where
 - force_unwrapping
 - multiline_parameters
 - number_separator
 - object_literal
 - operator_usage_whitespace
 - overridden_super_call
 - prohibited_super_call
 - redundant_nil_coalescing
 - sorted_imports
 - switch_case_on_newline
 - unneeded_parentheses_in_closure_argument
 - vertical_parameter_alignment_on_call
 - file_name_no_space

number_separator:
  minimum_length: 5

trailing_whitespace:
  ignores_comments: true

custom_rules:
  test_convention:
    name: "Unit test naming convention"
    message: "Expected test_MethodName_StateUnderTest_ExpectedBehavior()."
    regex: '(func test_([A-Za-z0-9]+_)*[a-z])'
  tabs_convention:
    name: "Tabs convention is not supported"
    message: "Use spaces instead."
    regex: '\t'
  one_line_convention:
    name: "Line between classes"
    message: "Add new line between each class/struct/enum/extension."
    regex: '^\}+(?!(\n$))'
parent_config: .swiftlint.yml

whitelist_rules:
 - trailing_whitespace
 - sorted_imports
 - vertical_whitespace
  • Which Xcode version are you using (check xcodebuild -version)? 15.3
// This triggers a violation:
var isScrollEnabled: Bool {
    get {
        collectionView.isScrollEnabled
    }
    set {
        collectionView.isScrollEnabled = newValue
    }
}

Note: The exactly same .yml with the exact same source code compiled correctly with Xcode 15.2

Try with version 0.54.0 please.

I do not get this violation with version 0.54.0. Is there a reason why SwiftLint suddenly started to trigger violations for implicit_getter simply by updating the Xcode version?

Pre 0.54.0, the rule was based on SourceKit which changes with every Xcode release. Like in your case, it might even change its behavior. Since 0.54.0, the rule is based on SwiftSyntax which is more stable in that regard.