Skip to content

Fix prefer_self_in_static_references for shadowed nested types#6552

Open
theamodhshetty wants to merge 1 commit intorealm:mainfrom
theamodhshetty:codex/fix-prefer-self-shadowed-inner-type
Open

Fix prefer_self_in_static_references for shadowed nested types#6552
theamodhshetty wants to merge 1 commit intorealm:mainfrom
theamodhshetty:codex/fix-prefer-self-shadowed-inner-type

Conversation

@theamodhshetty
Copy link
Copy Markdown
Contributor

Summary

  • skip prefer_self_in_static_references violations when a nested type shadows its enclosing type name
  • add a rule example covering the shadowed nested type case
  • add the changelog entry

Testing

  • swift test --filter PreferSelfInStaticReferencesRuleGeneratedTests
  • ./.build/debug/swiftlint lint Source/SwiftLintBuiltInRules/Rules/Style/PreferSelfInStaticReferencesRule.swift Source/SwiftLintBuiltInRules/Rules/Style/PreferSelfInStaticReferencesRuleExamples.swift CHANGELOG.md --strict
  • manual repro with only_rules: [prefer_self_in_static_references] against the struct S1 { struct S1 {}; var s = S1() } sample

@SwiftLintBot
Copy link
Copy Markdown

1 Warning
⚠️ This PR may need tests.
20 Messages
📖 Building this branch resulted in a binary size of 27359.09 KiB vs 27357.74 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.83 s vs 0.82 s on main (1% slower).
📖 Linting Alamofire with this PR took 1.07 s vs 1.04 s on main (2% slower).
📖 Linting Brave with this PR took 7.09 s vs 7.09 s on main (0% slower).
📖 Linting DuckDuckGo with this PR took 26.99 s vs 26.97 s on main (0% slower).
📖 Linting Firefox with this PR took 11.88 s vs 11.92 s on main (0% faster).
📖 Linting Kickstarter with this PR took 8.24 s vs 8.23 s on main (0% slower).
📖 Linting Moya with this PR took 0.48 s vs 0.45 s on main (6% slower).
📖 Linting NetNewsWire with this PR took 2.58 s vs 2.6 s on main (0% faster).
📖 Linting Nimble with this PR took 0.7 s vs 0.69 s on main (1% slower).
📖 Linting PocketCasts with this PR took 7.76 s vs 7.79 s on main (0% faster).
📖 Linting Quick with this PR took 0.47 s vs 0.46 s on main (2% slower).
📖 Linting Realm with this PR took 2.98 s vs 2.95 s on main (1% slower).
📖 Linting Sourcery with this PR took 1.85 s vs 1.84 s on main (0% slower).
📖 Linting Swift with this PR took 4.65 s vs 4.67 s on main (0% faster).
📖 Linting SwiftLintPerformanceTests with this PR took 0.35 s vs 0.35 s on main (0% slower).
📖 Linting VLC with this PR took 1.21 s vs 1.19 s on main (1% slower).
📖 Linting Wire with this PR took 18.63 s vs 18.67 s on main (0% faster).
📖 Linting WordPress with this PR took 12.63 s vs 12.64 s on main (0% faster).
📖 This PR fixed a violation in WordPress: /Modules/Sources/AsyncImageKit/ImageDownloader.swift:260:32: Warning: Use Self to refer to the surrounding type name (prefer_self_in_static_references)

Generated by 🚫 Danger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive for prefer_self_in_static_references when an inner struct has the same name as its owner

2 participants