realm / realm/SwiftLint

[unused_declaration] False positive when the conformance to a protocol happens on an extension in a different file

Open
#3,763 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

New Issue Checklist
Describe the bug

When running the unused_declaration analyze rule:

The rule will throw a false positive, detecting the conformance that happens in a different file as unused:

swift-compilation-database/Sources/ModuleB/Something+conformance.swift:2:10: error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted. (unused_declaration)
Environment
  • SwiftLint version (run swiftlint version to be sure)? 0.45.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? mint
  • Paste your configuration file:
analyzer_rules:
  - unused_import
  - unused_declaration

unused_declaration:
  include_public_and_open: true

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 with the unused_declaration analyzer and reproduce the report by cloning swift-compilation-database and running make go_with_xcodebuild. Inspect Sources/ModuleB/SomethingProtocol.swift and Sources/ModuleB/Something+conformance.swift, focusing on how declarations and conformances are considered across files. Done means the cross-file conformance is no longer reported as unused while genuine unused declarations remain detected.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.