Skip to content

UnnecessaryApply: fix false negative for assignment#4948

Merged
schalkms merged 1 commit into
detekt:mainfrom
dzirbel:unnecessaryApplyAssignment
Jun 27, 2022
Merged

UnnecessaryApply: fix false negative for assignment#4948
schalkms merged 1 commit into
detekt:mainfrom
dzirbel:unnecessaryApplyAssignment

Conversation

@dzirbel

@dzirbel dzirbel commented Jun 12, 2022

Copy link
Copy Markdown
Contributor

Fix a missed case of UnnecessaryApply where the apply contains a single field assignment but the result of the apply{} is unused. This pattern is actually used in 2/3 of the <noncompliant> examples and while it occurred in tests for false positives, no test actually checked that warnings were generated in the simple case.

I only added a few tests for the simple cases to avoid duplicating a number of the ones for function calls; more could be added for completeness but it would bloat the test file considerably.

@cortinico cortinico added this to the 1.21.0 milestone Jun 13, 2022
Fix a missed case of UnnecessaryApply where the apply contains a single field assignment but the result of the apply{} is unused. This pattern is actually used in 2/3 of the <noncompliant> examples and while it occurred in tests for false positives, no test actually checked that warnings were generated in the simple case.

@BraisGabin BraisGabin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@schalkms schalkms merged commit c8eb24c into detekt:main Jun 27, 2022
@dzirbel dzirbel deleted the unnecessaryApplyAssignment branch June 27, 2022 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants