-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Allow prefer_key_paths
to ignore identity closures ({ $0 }
)
#6068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow prefer_key_paths
to ignore identity closures ({ $0 }
)
#6068
Conversation
Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general. Thanks!
Please see my comments and rebase your branch to make all tests run (there are relevant fixes on main
).
|
||
static let description = RuleDescription( | ||
identifier: "prefer_key_path", | ||
name: "Prefer Key Path", | ||
description: "Use a key path argument instead of a closure with property access", | ||
description: """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the existing description as it's currently also used as the violation message and add a rational
property instead to explain this detail.
0b22e4f
to
cbf90c0
Compare
Ready for re-review @SimplyDanny Not sure what is causing the buildkite/swiftlint/bazel and buildkite/swiftlint/registration CI steps to fail, as I ran both command sequences locally and they succeed. They seem to be linker issues caused by some TSan symbols, so perhaps caused by some caching issue? Thanks 🙏🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a few more stylistic issue. Other than that, it looks good!
Source/SwiftLintBuiltInRules/Rules/Idiomatic/PreferKeyPathRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/PreferKeyPathRule.swift
Outdated
Show resolved
Hide resolved
Add new `ignore_identity_closures` parameter to `prefer_key_paths` rule to skip conversion of identity closures (`{ $0 }`) to identity key paths (`\self`). Add a small note to the rule description stating that identity key path conversion is Swift 6+ only.
Co-authored-by: Danny Mösch <[email protected]>
ca999dc
to
86890ba
Compare
Add new
ignore_identity_closures
parameter toprefer_key_paths
rule to skip conversion of identity closures ({ $0 }
) to identity key paths (\self
).Add a small note to the rule description stating that identity key path conversion is Swift 6+ only.