Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: skip redundant_optional_initialization for @Parameter variables …#6296

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
chetan-kmr-0607 wants to merge1 commit intorealm:main
base:main
Choose a base branch
Loading
fromchetan-kmr-0607:skip-parameter-init

Conversation

@chetan-kmr-0607
Copy link

…(#5884)

This change updates ImplicitOptionalInitializationRule so that variables annotated with@parameter (from TipKit) are ignored when checking for redundant nil initializers. TipKit's@parameter macro requires explicitly initializing optional parameters to nil; otherwise the macro fails to expand. Without this change, the implicit_optional_initialization rule incorrectly flags these initializers, forcing developers to disable the rule.

Resolves#5884.

…ealm#5884)This change updates ImplicitOptionalInitializationRule so that variables annotated with@parameter (from TipKit) are ignored when checking for redundant nil initializers. TipKit's@parameter macro requires explicitly initializing optional parameters to nil; otherwise the macro fails to expand. Without this change, the implicit_optional_initialization rule incorrectly flags these initializers, forcing developers to disable the rule.Resolvesrealm#5884.
Copy link
Collaborator

@SimplyDannySimplyDanny left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution. Before this can be merged, it would need tests and a changelog entry.

Generally, I think that the attributes for which the rule shall be ignored, should be configurable instead of being hard-coded.

@@ -1,4 +1,4 @@
import SwiftSyntax
eimport SwiftSyntax
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unintentional?

violations.append(ReasonedRuleViolation(position: violationPosition, reason: reason))
// // violations.append(ReasonedRuleViolation(position: violationPosition, reason: reason))
overridefunc visitPost(_ node:PatternBindingSyntax){
iflet variableDecl= node.parent?.as(VariableDeclSyntax.self),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks a bit off.

@SwiftLintBot
Copy link

1 Error
🚫OSSCheck was cancelled
1 Warning
⚠️If this is a user-facing change, please include a CHANGELOG entry to credit yourself!
You can find it atCHANGELOG.md.

Here's an example of your CHANGELOG entry:

* fix: skip redundant_optional_initialization for@Parameter variables ….[chetan-kmr-0607](https://github.com/chetan-kmr-0607)[#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by 🚫Danger

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@SimplyDannySimplyDannySimplyDanny requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Optional TipKit parameters trigger aredundant_optional_initialization violation

3 participants

@chetan-kmr-0607@SwiftLintBot@SimplyDanny

[8]ページ先頭

©2009-2025 Movatter.jp