realm / realm/SwiftLint

False positive: unused_declaration flagging projectedValue of property wrapper

Open
#3,237 4 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

Describe the bug

Swiftlint is identifying the projectedValue of a property wrapper as unused.

Environment
  • SwiftLint version (run swiftlint version to be sure)? 0.39.2

  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew

  • Are you using nested configurations? No

  • Which Xcode version are you using (check xcodebuild -version)? Xcode 11.3.1 Build version 11C505

  • Do you have a sample that shows the issue?

@propertyWrapper
final class LockedWhenRead<Value: Equatable> {
    /// Allows access outside of private scope.
    var projectedValue: LockedWhenRead<Value> { return self }

    var wrappedValue: Value {
        get { self.getAndLockValue() }
        set { self.storeAndSet(newValue) }
    }

    private func getAndLockValue() -> Value {
        ...
    }

    private func storeAndSet(_ newValue: Value) {
        ...
    }
}

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

Reproduce the reported example with SwiftLint 0.39.2 and the unused_declaration rule, focusing on the property wrapper's projectedValue. Trace how the rule classifies projectedValue and verify the fix against the sample so that a valid projectedValue is no longer reported as unused.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.