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

Universal/ConstructorDestructorReturn: ignore nested functions/closures #202

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jan 4, 2023

Closures and named (global) functions can be declared within a constructor/destructor method and can be declared to return a value.

As things were, the sniff did not take this into account and would throw false positives for the ReturnValueFound error code when this situation was encountered.

The fix as now applied, "jumps" over all nested function declarations within constructors/destructors (including arrow functions, even though thoe can't have a return).

Includes tests safeguarding this fix.

Fixes #201

Closures and named (global) functions can be declared _within_ a constructor/destructor method and can be declared to `return` a value.

As things were, the sniff did not take this into account and would throw false positives for the `ReturnValueFound` error code when this situation was encountered.

The fix as now applied, "jumps" over all nested function declarations within constructors/destructors (including arrow functions, even though thoe can't have a `return`).

Includes tests safeguarding this fix.

Fixes 201
@jrfnl jrfnl added this to the 1.x Next milestone Jan 4, 2023
@jrfnl jrfnl merged commit 936d574 into develop Jan 4, 2023
@jrfnl jrfnl deleted the feature/201-constructordestructorreturn-bug-fix-nested-functions branch January 4, 2023 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive in Universal.CodeAnalysis.ConstructorDestructorReturn
1 participant