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

Add the UseExplicitNilCheckInConditions rule. #627

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

allevato
Copy link
Member

This rule diagnoses and replaces occurrences of patterns like if let _ = x with if x != nil (likewise for conditions in guard and while statements). The rationale for this is that explicitly testing for nil is clearer about intent than binding and immediately discarding the wrapped value.

This rule diagnoses and replaces occurrences of patterns like
`if let _ = x` with `if x != nil` (likewise for conditions in
`guard` and `while` statements). The rationale for this is that
explicitly testing for `nil` is clearer about intent than
binding and immediately discarding the wrapped value.
@allevato
Copy link
Member Author

cc @dylansturg

Static properties of a type that return that type should not include a reference to their type.

Lint: Non-literal empty array initialization will yield a lint error.
Format: All invalid use sites would be related with empty literal (with or without explicit type annotation).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"would be replaced with empty literal..."?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a typo from earlier, there was a race between the generate-the-docs PR and the one adding this rule so it didn't get generated the first time. I'll update that in a separate follow-up because I need to do a pass over all the rule docs anyway to make sure they're formatted nicely in the new Markdown file.

@allevato allevato merged commit 2a6868a into swiftlang:main Sep 18, 2023
@allevato allevato deleted the no-discard-conditional-assignment branch September 18, 2023 12:52
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.

2 participants