SonarSource/sonar-dotnet

New Rule T0026: Indent chain invocation +4 further than the initial line

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;

This rule does not care about multiple members on the subsequent lines. That is T0027

object.Property.Children
.Select(x => x.Something) // Noncompliant
    .Where(x => x != null)
        .OrderBy(x => x.Rank) // Noncompliant
    .ToArray().ToArray().ToArray() // Compliant, out of scope
    .Length;