Skip to content
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

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

rakuyoMo
Copy link
Contributor

Fixed

This PR mainly fixes the following issues:

  • Fixed the issue that the newly added --nilInit insert option for redundantNilInit in 0.54.0 was incorrectly applied to computed properties.

Also I fixed some test case errors related to --nilInit insert.

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.11%. Comparing base (dd989a4) to head (836d8d7).
Report is 11 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

@@ -2183,12 +2185,13 @@ class RedundancyTests: RulesTests {
}
}
"""
let options = FormatOptions(nilInit: .remove)
Copy link
Collaborator

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

Copy link
Collaborator

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"
Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

@calda calda left a 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.

Copy link
Collaborator

@calda calda left a 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!

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.

None yet

2 participants