realm / realm/SwiftLint

`unused_setter_value` incorrectly gets triggered for an empty setter

Open
#3,863 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

acceptable-false-positive 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

The following code gets reported as a vioation of the unused_setter_value rule, even though it was one of the examples explicitly cited as being non-offending.

override var aValue: String {
  get {
    return Persister.shared.aValue
  }
  set() { }

There might be a meta-issue here, about why the example didn't cause a test failure.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Environment
  • SwiftLint version: 0.46.3

  • Installation method used: Homebrew

  • Which Xcode version are you using (check xcodebuild -version)? Xcode 13.2.1 Build version 13C100

  • Do you have a sample that shows the issue? Yes:

    echo 'private var abc: Int { get { 123 } set() { } }' | swiftlint lint --no-cache --use-stdin --enable-all-rules`

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 reproducing the unused_setter_value report with swiftlint lint --no-cache --use-stdin --enable-all-rules and the empty-setter sample. Trace the unused_setter_value rule and its existing examples or tests, then confirm that the empty setter no longer produces a violation while other offending cases still do.

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
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.