realm / realm/SwiftLint

explicit_self does not support property wrappers

Open
#3,377 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

New Issue Checklist
Describe the bug

explicit_self gets completely ignored with default triggering examples. I noticed this a long time ago, but thought that this might be due to complex code. Just tested this with default examples in isolated environment and stripped down configuration.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Loading configuration from '.swiftlint.yml'
Linting Swift files at paths 
Linting 'Lint.swift' (1/1)
Done linting! Found 0 violations, 0 serious in 1 file.
Environment
  • SwiftLint version: 0.40.3
  • Installation method used: Homebrew
  • Paste your configuration file:
included: .

opt_in_rules:
  - explicit_self
  
disabled_rules:
  - identifier_name
  - type_name
  • Are you using nested configurations? No
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 12.0.1 Build version 12A7300
  • Do you have a sample that shows the issue?
internal struct A {
    func f1() {}
    func f2() {
        ↓f1()
    }
}
internal struct A {
    let p1: Int
    func f1() {
        _ = ↓p1
    }
}
@propertyWrapper
internal struct Wrapper<Value> {
    let wrappedValue: Value
    var projectedValue: [Value] {
        [self.wrappedValue]
    }
}
internal struct A {
    @Wrapper var p1: Int
    func f1() {
        ↓$p1
        ↓_p1
    }
}
internal func f1() {
    A(p1: 10).$p1
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running swiftlint lint with the provided .swiftlint.yml against the sample containing @Wrapper, $p1, and _p1, then compare the result with the explicit_self triggering examples. Trace how the explicit_self rule handles property-wrapper references. Done means the previously ignored references are reported consistently with the rule's expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.