New Rule: Implicit Optional Initialisation#6165
Conversation
Generated by 🚫 Danger |
ac0062a to
79e79bb
Compare
|
As a general remark: There is a way of deprecating an existing rule, adding |
421962b to
49cd8d8
Compare
Are you going to merge the new rule into the existing one, @leo-lem? |
We could. The new rule does cover all cases of the old one. The difference is that it wouldn't be active by default. I was going off of the comment to the issue:
But I am also open to introducing it as a new style rule in addition to the old rule. What are your thoughts on this, @SimplyDanny? |
137ac44 to
049e210
Compare
I see. That |
|
so remove the |
Yes. I didn't check, but all the test cases from There is also a better report categorizing fixed and new violations. I can post it here after the removal of the old rule in case you cannot access it. |
|
summary looks good to me :) |
SimplyDanny
left a comment
There was a problem hiding this comment.
OSS report looks good. It shows that the new rule behaves like the replaces one by default.
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
f83378e to
dbef6ad
Compare
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/RuleConfigurations/ImplicitOptionalInitConfiguration.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitRuleExamples.swift
Outdated
Show resolved
Hide resolved
|
@SimplyDanny there seems to be no space left on the buildkite device, how can we fix that? |
I can try to clean this up later. Unrelated: Please prefer rebase over merge of |
…ntialization with style always the default.
* fix indendation. * extract examples into separate file for readability. * improve description and add reasoned violation. * Change violation position to variable name. * other small cleanups.
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
* Move violation position to start of node.
* Move reason property up and hardcode recommendation.
624e60a to
ab7ce26
Compare
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRule.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
Source/SwiftLintBuiltInRules/Rules/Style/ImplicitOptionalInitializationRuleExamples.swift
Show resolved
Hide resolved
|
Thank you for all the work, @leo-lem! That's good to be merged now. |
Add
implicit_optional_initializationRuleThis PR introduces a new rule:
implicit_optional_initialization, replacing the previousredundant_optional_initializationrule, which has been deprecated using thedeprecationAliasfield.About the new rule
The rule enforces whether optional variables should always be implicitly initialized (i.e., rely on Swift’s default behavior) or never by always adding
= nil.The default is always (matching the old rule).
The rule is NOT enabled by default.
It is configurable via the
styleparameter:✅ Non-triggering examples
🔴 Triggering examples
🛠 Corrections
The rule is correctable in both directions depending on the
style:= nilas appropriateImplementation notes
@SwiftSyntaxRule)default_rule_configurations.ymlredundant_optional_initializationwith finer control.Closes #1940