realm / realm/SwiftLint

`prefer_self_in_static_references` doesn't report violations in extensions

Open
#6,828 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

New Issue Checklist
Bug Description

prefer_self_in_static_references doesn't report violations in extensions

struct Example {
	var value = 1
}

extension Example {
	static func example() -> Example { // no violation reported here
		.init()
	}
}
$ swiftlint lint --quiet --only-rule prefer_self_in_static_references Sources
Environment
  • SwiftLint version: 0.65.0
  • Xcode version: Xcode 26.6 / Build version 17F113
  • Installation method: Homebrew
  • Configuration file: occurs even if no config file

Are you using nested configurations? No

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 the provided swiftlint lint command against the Swift extension example with only prefer_self_in_static_references enabled. Trace how that rule handles static references in extensions, then verify that the .init() call is reported as a violation while the existing behavior remains intact.

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
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.