Moderne OnlyThis recipe is proprietary to Moderne and runs on the Moderne platform or CLI — it isn’t part of the open-source catalog. Available with a Moderne subscription.
LINQ code quality
Recipe ID
OpenRewrite.Recipes.CSharp.CodeQuality.Linq.LinqCodeQualityArtifact
OpenRewrite.Recipes.CSharp.CodeQualityDefinition
Recipes23
23 recipes
- Optimize LINQ Where().Any()
- Optimize LINQ Where().Count()
- Optimize LINQ Where().First()
- Optimize LINQ Where().FirstOrDefault()
- Optimize LINQ Where().Single()
- Optimize LINQ Where().SingleOrDefault()
- Optimize LINQ Where().Last()
- Optimize LINQ Where().LastOrDefault()
- Optimize LINQ Where().LongCount()
- Optimize LINQ Select().Max()
- Optimize LINQ Select().Min()
- Optimize LINQ Select().Sum()
- Optimize LINQ Select().Average()
- Use ThenBy instead of second OrderBy
- Use OrderBy().ThenByDescending()
- Use OrderByDescending().ThenByDescending()
- Use Order() instead of OrderBy() with identity
- Remove useless OrderBy call
- Use Cast<T>() instead of Select with cast
- Combine LINQ methods
- Use Where before OrderBy
- Use Any() instead of Count() > 0
- Find Count() comparison that could be optimized
Usage
Run this recipe
In order to run C# recipes, you will need to use the Moderne CLI.
Once the CLI is installed, you can install this C# recipe package by running the following command:
Install the recipe package
mod config recipes nuget install OpenRewrite.Recipes.CSharp.CodeQuality
Then, you can run the recipe via:
Run the recipe
mod run . --recipe OpenRewrite.Recipes.CSharp.CodeQuality.Linq.LinqCodeQuality