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

Simple condition parts should be placed on same line (MiKo_6048) #997

Open
RalfKoban opened this issue Aug 15, 2024 · 0 comments
Open

Simple condition parts should be placed on same line (MiKo_6048) #997

RalfKoban opened this issue Aug 15, 2024 · 0 comments

Comments

@RalfKoban
Copy link
Owner

RalfKoban commented Aug 15, 2024

We should report an issue in case a "simple" binary condition spans multiple lines.

Following condition should trigger:

public object SomeProperty { get; set; }

public void DoSomething(object o)
{
    if (SomeProperty != null
        && SomeProperty.Equals(o))
    { }
}

It should be fixed to

public object SomeProperty { get; set; }

public void DoSomething(object o)
{
    if (SomeProperty != null && SomeProperty.Equals(o))
    { }
}

Same is valid for some more complex parts:

public object SomeProperty1 { get; set; }

public object SomeProperty2 { get; set; }

public void DoSomething(object o)
{
    if ((SomeProperty1 != null
        && SomeProperty1.Equals(o))
     || (SomeProperty2 != null
        && SomeProperty2.Equals(o)))
    { }
}

It should be fixed to something like

public object SomeProperty1 { get; set; }

public object SomeProperty2 { get; set; }

public void DoSomething(object o)
{
    if ((SomeProperty1 != null && SomeProperty1.Equals(o))
     || (SomeProperty2 != null && SomeProperty2.Equals(o)))
    { }
}

In addition, following conditions should report as well:

if (xyz is 
            IReadOnlyCollection<string> collection)

if (xyz is IReadOnlyCollection<string>
     collection)

if (xyz
    is IReadOnlyCollection<string> collection)

if (xyz
    is IReadOnlyCollection<string>
      collection)

They should be fixed to

if (xyz is IReadOnlyCollection<string> collection)
@RalfKoban RalfKoban changed the title Simple AND / OR conditions should be placed on same line Simple condition parts should be placed on same line Aug 15, 2024
@RalfKoban RalfKoban changed the title Simple condition parts should be placed on same line Simple condition parts should be placed on same line (MiKo_6048) Aug 15, 2024
RalfKoban added a commit that referenced this issue Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: On hold
Development

No branches or pull requests

1 participant