Java Recipe best practices
MSALBest practices for Java recipe development.
org. openrewrite. java. recipes. JavaRecipeBestPracticesmod run . --recipe= org. openrewrite. java. recipes. JavaRecipeBestPracticesInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.
Recipe list
It runs these recipes, in this order.
- Add a blank line around fields with annotations
- Correctly spaced descriptions
- Use a standard name for
ExecutionContext - Find method calls and say what to do instead
- Find method calls and say what to do instead
- Find method calls and say what to do instead
- Find method calls and say what to do instead
- Find method calls and say what to do instead
- Find method calls and say what to do instead
- Inline nested visitor classes into the returning method
- Use
J.Literal.isLiteralValue(expression, null) - Use
ListUtils.filterinstead of mapping elements tonull - Find missing
@Optionexamplevalues - Recipe classes should not have mutable
staticfields - Use of
@EqualsAndHashCodeonRecipe - Recipe classes should be public
- Drop redundant conditions around
maybeAddImportandmaybeRemoveImport - Reorder
maybeRemoveImportbeforemaybeAddImport - Make matcher fields
static finalconstants - Replace
getDisplayName()andgetDescription()methods with fields - Replace
getEstimatedEffortPerOccurrence()method with field - Use
StringUtilsutility methods - Replace
getTags()method with field - Use
JavaTemplate.apply()static method - Use
UsesMethodandDeclaresMethodpreconditions withMethodMatchers - Use
Tree.randomId()in LST constructors - Use
visitwith parent cursor when calling from another visitor - Use
TreeVisitor#reduceinstead of a captured accumulator - Fix missing braces
- Remove
System.out#printlnandSystem.err#printlnstatements - Remove
@NlsRewriteannotations fromRecipeclasses