Skip to content

Ignore more locations of static references not using 'Self' in classes - #3771

Merged
jpsim merged 3 commits into
realm:masterfrom
SimplyDanny:ignore-more-locations-in-classes
Jan 21, 2022
Merged

jpsim merged 3 commits into
realm:masterfrom
SimplyDanny:ignore-more-locations-in-classes

Conversation

@SimplyDanny

Copy link
Copy Markdown
Collaborator

This fixes #3768. Static references with Self are not allowed to define

  • default values of properties,
  • annotation parameter values and
  • default method parameter values

in classes.

@SwiftLintBot

SwiftLintBot commented Dec 1, 2021 •

Copy link
Copy Markdown
3 Warnings
⚠️ This PR may need tests.
⚠️ This PR changed the exit value when running on Firefox: (pid 50161 SIGABRT (signal 6) to pid 49182 exit 0)
⚠️ This PR changed the exit value when running on Swift: (pid 50291 SIGABRT (signal 6) to pid 49313 SIGTRAP (signal 5))
42 Messages
📖 Linting Aerial with this PR took 0.24s vs 0.23s on master (4% slower)
📖 Linting Alamofire with this PR took 0.27s vs 0.27s on master (0% slower)
📖 Linting Firefox with this PR took 1.1s vs 1.07s on master (2% slower)
📖 Linting Kickstarter with this PR took 1.81s vs 1.8s on master (0% slower)
📖 Linting Moya with this PR took 0.13s vs 0.13s on master (0% slower)
📖 Linting Nimble with this PR took 0.13s vs 0.13s on master (0% slower)
📖 Linting Quick with this PR took 0.07s vs 0.07s on master (0% slower)
📖 Linting Realm with this PR took 0.79s vs 0.8s on master (1% faster)
📖 Linting SourceKitten with this PR took 0.11s vs 0.11s on master (0% slower)
📖 Linting Sourcery with this PR took 0.38s vs 0.38s on master (0% slower)
📖 Linting Swift with this PR took 1.18s vs 1.16s on master (1% slower)
📖 Linting WordPress with this PR took 2.02s vs 2.02s on master (0% slower)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:516:54: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:517:48: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:518:56: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:636:54: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:638:48: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:639:56: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:782:54: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:783:48: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:784:56: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:943:54: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:945:48: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/ResponseSerialization.swift:946:56: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/RetryPolicy.swift:292:36: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/RetryPolicy.swift:293:48: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/RetryPolicy.swift:294:51: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/RetryPolicy.swift:295:57: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/RetryPolicy.swift:296:54: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Alamofire: /Source/RetryPolicy.swift:297:62: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Moya: /Sources/Moya/MoyaProvider.swift:95:62: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Moya: /Sources/Moya/MoyaProvider.swift:96:60: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Moya: /Sources/Moya/MoyaProvider.swift:97:54: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Sourcery: /SourceryJS/Sources/EJSTemplate.swift:69:57: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Sourcery: /SourceryJS/Sources/EJSTemplate.swift:73:69: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Sourcery: /SourceryJS/Sources/EJSTemplate.swift:79:57: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Sourcery: /SourceryTests/Stub/Performance-Code/Kiosk/Auction Listings/ListingsViewModel.swift:69:45: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Sourcery: /SourceryTests/Stub/Performance-Code/Kiosk/Auction Listings/ListingsViewModel.swift:70:95: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in Sourcery: /SourceryTests/Stub/Performance-Code/Kiosk/Auction Listings/ListingsViewModel.swift:71:115: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Stats/Shared Views/Date Chooser/SiteStatsTableHeaderView.swift:78:47: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/System/Notices/NoticePresenter.swift:63:162: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)
📖 This PR fixed a violation in WordPress: /WordPress/WordPressTest/PostBuilder.swift:11:46: warning: Prefer Self in Static References Violation: Static references should be prefixed by Self instead of the class name. (prefer_self_in_static_references)

Generated by 🚫 Danger

@SimplyDanny

Copy link
Copy Markdown
Collaborator Author

The changes cause an exception for declarations involving private(set) since this is seen as an attribute, too. The fix will take some more time.

@SimplyDanny

Copy link
Copy Markdown
Collaborator Author

The changes cause an exception for declarations involving private(set) since this is seen as an attribute, too. The fix will take some more time.

This issue and the compilation failures reported in #3768 should be fixed with the latest commit.

The failed run on the Swift repository reported by @SwiftLintBot above is caused by the file validation-test/compiler_crashers_fixed/25533-bool.swift which contains the only line extension(Int[a,Int. It is clearly invalid Swift code, but SourceKitten interprets it as a declaration. How to deal with that? I guess it is not okay if SwiftLint aborts with a fatal error on invalid input?

A possible solution is to check whether the name of the declaration is a valid Swift identifier. Such a check is not straightforward. Is there something similar somewhere in the code already?

@jpsim

jpsim commented Jan 21, 2022

Copy link
Copy Markdown
Collaborator

I guess it is not okay if SwiftLint aborts with a fatal error on invalid input?

I've taken the approach with SwiftLint that it only really makes sense to operate on valid Swift code, so this is fine.

@jpsim
jpsim force-pushed the ignore-more-locations-in-classes branch from 5ee227b to ae35561 Compare January 21, 2022 18:41
@jpsim
jpsim enabled auto-merge January 21, 2022 18:41
@jpsim

jpsim commented Jan 21, 2022

Copy link
Copy Markdown
Collaborator

Thanks for these fixes!

SimplyDanny and others added 3 commits January 21, 2022 21:08
Static references with `Self` are not allowed to define

* default values of properties,
* annotation parameter values and
* default method parameter values

in classes.
auto-merge was automatically disabled January 21, 2022 20:11

Head branch was pushed to by a user without write access

@SimplyDanny
SimplyDanny force-pushed the ignore-more-locations-in-classes branch from ae35561 to c912637 Compare January 21, 2022 20:11
@jpsim

jpsim commented Jan 21, 2022

Copy link
Copy Markdown
Collaborator

@SimplyDanny I'll merge this as-is so I can cut a release before I log off for the weekend. Any additional fixes can come in a follow-up release.

@jpsim
jpsim merged commit d99be66 into realm:master Jan 21, 2022
@SimplyDanny

SimplyDanny commented Jan 21, 2022 •

Copy link
Copy Markdown
Collaborator Author

I'll merge this as-is so I can cut a release before I log off for the weekend. Any additional fixes can come in a follow-up release.

Alright. I just resolved a merge conflict in the CHANGELOG.md with the update a few minutes ago.

@SimplyDanny
SimplyDanny deleted the ignore-more-locations-in-classes branch January 21, 2022 20:49
rcole34 pushed a commit to rcole34/SwiftLint that referenced this pull request Feb 22, 2022
realm#3771)

Static references with `Self` are not allowed to define

* default values of properties,
* annotation parameter values and
* default method parameter values

in classes.
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.

Compilation errors after following new rule prefer_self_in_static_references

3 participants