Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.3 KB

File metadata and controls

45 lines (35 loc) · 1.3 KB

PH2104: Every LINQ statement on separate line

Property Value
Package Philips.CodeAnalysis.MaintainabilityAnalyzers
Diagnostic ID PH2104
Category Readability
Analyzer EveryLinqStatementOnSeparateLineAnalyzer
CodeFix Yes
Severity Error
Enabled By Default Yes

Introduction

Avoid putting multiple LINQ statements on a single line, as it makes them hard to read.

How to solve

Spread them over multiple lines. This is what the Code fixer does.

Example

Code that triggers a diagnostic:

class BadExample {
  public int BadMethod() {
    return list.Where(i => i != 1).Select(t => t.ToString());
  }
}

And the replacement code:

class GoodExample {
  public int GoodMethod() {
    return list
      .Where(i => i != 1)
      .Select(t => t.ToString());
  }
}

Configuration

This analyzer does not offer any special configuration. The general ways of suppressing diagnostics apply.