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

Orphan variable since v0.27.1 #1153

Closed
aurnoi1 opened this issue Jan 27, 2024 · 1 comment · Fixed by #1155
Closed

Orphan variable since v0.27.1 #1153

aurnoi1 opened this issue Jan 27, 2024 · 1 comment · Fixed by #1155
Milestone

Comments

@aurnoi1
Copy link

aurnoi1 commented Jan 27, 2024

Supporting classes

public class Something
{
    public string SecondaryEmail => string.Empty;
}

public static class MaybeExtenstions
{
    public static string Match(this string value, Func<string> none, Func<string, string> some)
    {
        if (string.IsNullOrEmpty(value))
        {
            return none();
        }

        return some(value);
    }
}

Input:
v0.27.0

using FluentAssertions;

namespace Functario.Core.UnitTests;

public class FormatTests
{
    [Fact]
    public void MyTestMethod()
    {
        var a = new Something();

        a.SecondaryEmail.Match(
            none: () => "____________________________________________________",
            some: v => "____________________________________________________"
        )             // note that the parenthese is also orphean
            .Should()
            .Be("____________________________________________________");
    }
}

Output:
v0.27.1

public class FormatTests
{
    [Fact]
    public void MyTestMethod()
    {
        var a = new Something();

        a              // 'a' is orphean
            .SecondaryEmail.Match(
                none: () => "____________________________________________________",
                some: v => "____________________________________________________"
            ) // parenthese is aligned
            .Should()
            .Be("____________________________________________________");
    }
}

Expected behavior:

public class FormatTests
{
    [Fact]
    public void MyTestMethod()
    {
        var a = new Something();

        a.SecondaryEmail           // 'a' is no more orphean
            .Match(           // 'Match' could also be on the same lign that 'a.SecondaryEmail'
                none: () => "____________________________________________________",
                some: v => "____________________________________________________"
            )               // parenthese is aligned
            .Should()
            .Be("____________________________________________________");
    }
}

FYI:

  • The short length variable 'a' is a lambda variable in the original code.

Thanks!

@belav
Copy link
Owner

belav commented Jan 27, 2024

I created #1154 to split part of this out. The orphaned ) has been around for a while and exists in prettier as well.

Thanks for reporting the bug!

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 a pull request may close this issue.

2 participants