Select(x => x) returns every element unchanged
What it finds
A projection that returns its argument adds an iterator and nothing else. It can be removed; where it hides the type of the source on purpose, AsEnumerable() says so.
From the rule's source, identity_select.rs.
using System.Collections.Generic;using System.Linq; class Names{ IEnumerable<string> All(IEnumerable<string> names) => names.Select(n => n);tx0 reports: this Select returns each element unchanged IEnumerable<string> Upper(IEnumerable<string> names) => names.Select(n => n.ToUpper());} Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:identity-select" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:identity-select] reason="..."tx0 explain tx0/csharp:identity-select shows the same in the terminal. Found a false positive? Report it.