-
Notifications
You must be signed in to change notification settings - Fork 623
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
Fix --nilInit insert
being applied to computed property
#1735
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1735 +/- ##
===========================================
+ Coverage 95.21% 96.11% +0.90%
===========================================
Files 20 20
Lines 22882 23973 +1091
===========================================
+ Hits 21786 23041 +1255
+ Misses 1096 932 -164 ☔ View full report in Codecov by Sentry. |
@@ -2183,12 +2185,13 @@ class RedundancyTests: RulesTests { | |||
} | |||
} | |||
""" | |||
let options = FormatOptions(nilInit: .remove) |
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.
Why change this test case from nilInit: .remove
to nilInit: .insert
? It seems like now we don't have a test case for the .remove
case in a result builder
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.
Ok, I think I understand -- since the input doesn't include = nil
this test using the nilInit: .remove
seems like it wasn't actually testing anything before. The test does seem to make more sense now using nilInit: .insert
.
@@ -2045,14 +2045,14 @@ class RedundancyTests: RulesTests { | |||
} | |||
|
|||
func testNoInsertLazyVarNilInit() { | |||
let input = "lazy var foo: Int? = nil" |
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.
Why remove the = nil
from all of these existing test cases?
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 think I understand -- the input = nil
so nilInit: .insert
wouldn't have anything to do, making the previous test mostly redundant. The changes seem to align properly with the existing method names and make sense to me.
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.
Yes, this test case was originally intended to test "do not automatically add nil to lazy-modified variables", but it was written incorrectly before.
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.
The new changes look good, but I have some questions about why it was necessary to modify the existing tests.
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.
Thanks for the fix!
Fixed
This PR mainly fixes the following issues:
--nilInit insert
option forredundantNilInit
in 0.54.0 was incorrectly applied to computed properties.Also I fixed some test case errors related to
--nilInit insert
.