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.
Simplification code quality
Recipe ID
OpenRewrite.Recipes.CSharp.CodeQuality.Simplification.SimplificationCodeQualityArtifact
OpenRewrite.Recipes.CSharp.CodeQualityDefinition
Recipes60
60 recipes
- Remove redundant boolean literal
- Simplify boolean comparison
- Use compound assignment
- Simplify logical negation
- Simplify conditional expression
- Use coalesce expression
- Merge else with nested if
- Merge if with parent if
- Use postfix increment/decrement
- Simplify numeric comparison
- Use string.StartsWith instead of IndexOf comparison
- Simplify Nullable<T>.HasValue
- Use string interpolation instead of string.Format
- Use conditional access
- Convert 'if' to assignment
- Use conditional throw expression
- Merge consecutive Where calls
- Remove unnecessary braces
- Simplify nested using statement
- Use throw expression
- Use switch expression
- Use default literal
- Simplify do-while(true) to while(true)
- Use pattern matching instead of as
- Use pattern matching instead of is
- Simplify lazy initialization
- Use exception filter
- Convert anonymous method to lambda
- Use range operator
- Simplify negated is null pattern
- Use 'not' pattern instead of negation
- Use string.EndsWith
- Use short-circuit operator
- Use ^ operator for boolean inequality
- Merge switch sections with equivalent content
- Inline local variable
- Use for statement instead of while
- Simplify coalesce expression
- Expression is always true or false
- Convert interpolated string to concatenation
- Use string interpolation instead of concatenation
- Simplify code branching
- Join string expressions
- Use conditional access instead of conditional expression
- Simplify Nullable<T> to T?
- Combine 'Enumerable.Where' method chain
- Unconstrained type parameter checked for null
- Use 'is' operator instead of 'as' operator
- Use anonymous function or method group
- Operator is unnecessary
- Inline lazy initialization
- Use Guid.Empty
- Use DateTime.UnixEpoch
- Use DateTimeOffset.UnixEpoch
- Use TimeSpan.Zero
- Use string.Equals instead of == for string comparison
- Use pattern matching for equality comparison
- Use pattern matching for inequality comparison
- Use pattern matching instead of HasValue
- Use 'is' pattern instead of SequenceEqual
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.Simplification.SimplificationCodeQuality