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 bug in unusedArguments when shadowing function argument with conditional assignment declaration #1687

Conversation

calda
Copy link
Contributor

@calda calda commented Apr 25, 2024

This PR fixes a bug in the unusedArguments rule when shadowing a function argument with a declaration where the value is an if or switch expression.

Before (argument unexpectedly marked as unused)

func test(foo _: Foo) {
    let foo =
        if foo.bar {
            baaz
        } else {
            bar
        }
    print(foo)
}

After (preserved)

func test(foo: Foo) {
    let foo =
        if foo.bar {
            baaz
        } else {
            bar
        }
    print(foo)
}

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.20%. Comparing base (3ed1b63) to head (fbd398e).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1687   +/-   ##
========================================
  Coverage    95.19%   95.20%           
========================================
  Files           21       21           
  Lines        23019    23023    +4     
========================================
+ Hits         21913    21918    +5     
+ Misses        1106     1105    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@calda calda force-pushed the cal--unusedArguments-conditionalAssignment branch from 3f39a30 to fbd398e Compare April 25, 2024 21:08
@nicklockwood nicklockwood merged commit 73dee8b into nicklockwood:develop Apr 28, 2024
7 checks passed
nicklockwood pushed a commit that referenced this pull request May 12, 2024
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