SonarSource/sonar-dotnet

New Rule T0027: Move subsequent expressions on separate lines

Opened this issue · 0 comments

Coding style:

Chained invocations and member accesses violating S103 can have a chain of properties on the first line. Every other .Invocation() or .Member should be on a separate line, aligned with a left-most single indentation.

object.Property.Children
    .Select(x => x.Something)
    .Where(x => x != null)
    .OrderBy(x => x.Rank)
    .ToArray()
    .Length;

Exception from this rule: Chains of assertions can have supporting properties, .Should() and assertion on the same line.

values.Should().HaveCount(2)
    .And.ContainSingle(x => x.HasConstraint(BoolConstraint.True))
    .And.ContainSingle(x => x.HasConstraint(BoolConstraint.False));

This rule doesn't care about the indentation, that is in T0026.

Statements containing .Should() should be ignored.