Skip to content

Commit a16312f

Browse files
Replace getDisplayName() and getDescription() methods with fields
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.UseDisplayNameAndDescriptionFields?organizationId=QUxML01vZGVybmUvTW9kZXJuZSArIE9wZW5SZXdyaXRl Co-authored-by: Moderne <[email protected]>
1 parent 3d595ac commit a16312f

14 files changed

+28
-114
lines changed

src/main/java/org/openrewrite/java/dependencies/AddDependency.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,11 @@ public class AddDependency extends ScanningRecipe<AddDependency.Accumulator> {
127127
@Nullable
128128
Boolean acceptTransitive;
129129

130-
@Override
131-
public String getDisplayName() {
132-
return "Add Gradle or Maven dependency";
133-
}
130+
String displayName = "Add Gradle or Maven dependency";
134131

135-
@Override
136-
public String getDescription() {
137-
return "For a Gradle project, add a gradle dependency to a `build.gradle` file in the correct configuration " +
132+
String description = "For a Gradle project, add a gradle dependency to a `build.gradle` file in the correct configuration " +
138133
"based on where it is used. Or For a maven project, Add a Maven dependency to a `pom.xml` file in the " +
139134
"correct scope based on where it is used.";
140-
}
141135

142136
@Override
143137
public Accumulator getInitialValue(ExecutionContext ctx) {

src/main/java/org/openrewrite/java/dependencies/DependencyInsight.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,10 @@ public class DependencyInsight extends Recipe {
2727
// Populated by the other DependencyInsight visitors. Listed here so the saas knows to display this when the recipe runs
2828
transient DependenciesInUse dependenciesInUse = new DependenciesInUse(this);
2929

30-
@Override
31-
public String getDisplayName() {
32-
return "Dependency insight for Gradle and Maven";
33-
}
30+
String displayName = "Dependency insight for Gradle and Maven";
3431

35-
@Override
36-
public String getDescription() {
37-
return "Finds dependencies, including transitive dependencies, in both Gradle and Maven projects. " +
32+
String description = "Finds dependencies, including transitive dependencies, in both Gradle and Maven projects. " +
3833
"Matches within all Gradle dependency configurations and Maven scopes.";
39-
}
4034

4135
@Option(displayName = "Group pattern",
4236
description = "Group ID glob pattern used to match dependencies.",

src/main/java/org/openrewrite/java/dependencies/DependencyList.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,10 @@ public class DependencyList extends Recipe {
7676
*/
7777
transient Set<GroupArtifactVersion> seenGradleProjects = new HashSet<>();
7878

79-
@Override
80-
public String getDisplayName() {
81-
return "Dependency report";
82-
}
79+
String displayName = "Dependency report";
8380

84-
@Override
85-
public String getDescription() {
86-
return "Emits a data table detailing all Gradle and Maven dependencies. " +
81+
String description = "Emits a data table detailing all Gradle and Maven dependencies. " +
8782
"This recipe makes no changes to any source file.";
88-
}
8983

9084
@Override
9185
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/dependencies/DependencyResolutionDiagnostic.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,9 @@ public class DependencyResolutionDiagnostic extends ScanningRecipe<DependencyRes
4646
transient RepositoryAccessibilityReport report = new RepositoryAccessibilityReport(this);
4747
transient GradleDependencyConfigurationErrors gradleErrors = new GradleDependencyConfigurationErrors(this);
4848

49-
@Override
50-
public String getDisplayName() {
51-
return "Dependency resolution diagnostic";
52-
}
49+
String displayName = "Dependency resolution diagnostic";
5350

54-
@Override
55-
public String getDescription() {
56-
//language=markdown
57-
return "Recipes which manipulate dependencies must be able to successfully access the artifact repositories " +
51+
String description = "Recipes which manipulate dependencies must be able to successfully access the artifact repositories " +
5852
"and resolve dependencies from them. This recipe produces two data tables used to understand the state " +
5953
"of dependency resolution. \n\n" +
6054
"The Repository accessibility report lists all the artifact repositories known to the project and whether " +
@@ -63,7 +57,6 @@ public String getDescription() {
6357
"The Gradle dependency configuration errors lists all the dependency configurations that failed to " +
6458
"resolve one or more dependencies when the project was parsed. This is representative of conditions at " +
6559
"the time the LST was parsed.";
66-
}
6760

6861

6962
@Option(displayName = "Group ID",

src/main/java/org/openrewrite/java/dependencies/FindDependency.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,12 @@ public class FindDependency extends Recipe {
5656
@Nullable
5757
String configuration;
5858

59-
@Override
60-
public String getDisplayName() {
61-
return "Find Maven and Gradle dependencies";
62-
}
59+
String displayName = "Find Maven and Gradle dependencies";
6360

64-
@Override
65-
public String getDescription() {
66-
return "Finds direct dependencies declared in Maven and Gradle build files. " +
61+
String description = "Finds direct dependencies declared in Maven and Gradle build files. " +
6762
"This does *not* search transitive dependencies. " +
6863
"To detect both direct and transitive dependencies use `org.openrewrite.java.dependencies.DependencyInsight` " +
6964
"This recipe works for both Maven and Gradle projects.";
70-
}
7165

7266
@Override
7367
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/dependencies/RelocatedDependencyCheck.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,13 @@ public class RelocatedDependencyCheck extends ScanningRecipe<RelocatedDependency
5252
@Nullable
5353
Boolean changeDependencies;
5454

55-
@Override
56-
public String getDisplayName() {
57-
return "Find relocated dependencies";
58-
}
55+
String displayName = "Find relocated dependencies";
5956

60-
@Override
61-
public String getDescription() {
62-
//language=markdown
63-
return "Find Maven and Gradle dependencies and Maven plugins that have relocated to a new `groupId` or `artifactId`. " +
57+
String description = "Find Maven and Gradle dependencies and Maven plugins that have relocated to a new `groupId` or `artifactId`. " +
6458
"Relocation information comes from the [oga-maven-plugin](https://github.com/jonathanlermitage/oga-maven-plugin/) " +
6559
"maintained by Jonathan Lermitage, Filipe Roque and others.\n\n" +
6660
"This recipe makes no changes to any source file by default. Add `changeDependencies=true` to change dependencies, " +
6761
"but note that you might need to run additional recipes to update imports and adopt other breaking changes.";
68-
}
6962

7063
@Value
7164
public static class Accumulator {

src/main/java/org/openrewrite/java/dependencies/RemoveDependency.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,10 @@ public class RemoveDependency extends ScanningRecipe<Map<JavaProject, Boolean>>
6363
@Nullable
6464
String scope;
6565

66-
@Override
67-
public String getDisplayName() {
68-
return "Remove a Gradle or Maven dependency";
69-
}
66+
String displayName = "Remove a Gradle or Maven dependency";
7067

71-
@Override
72-
public String getDescription() {
73-
return "For Gradle project, removes a single dependency from the dependencies section of the `build.gradle`.\n" +
68+
String description = "For Gradle project, removes a single dependency from the dependencies section of the `build.gradle`.\n" +
7469
"For Maven project, removes a single dependency from the `<dependencies>` section of the pom.xml.";
75-
}
7670

7771
@Override
7872
public Map<JavaProject, Boolean> getInitialValue(ExecutionContext ctx) {

src/main/java/org/openrewrite/java/dependencies/RemoveRedundantDependencies.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,11 @@ public class RemoveRedundantDependencies extends ScanningRecipe<RemoveRedundantD
4646
example = "jackson-databind")
4747
String artifactId;
4848

49-
@Override
50-
public String getDisplayName() {
51-
return "Remove redundant explicit dependencies";
52-
}
49+
String displayName = "Remove redundant explicit dependencies";
5350

54-
@Override
55-
public String getDescription() {
56-
return "Remove explicit dependencies that are already provided transitively by a specified dependency. " +
51+
String description = "Remove explicit dependencies that are already provided transitively by a specified dependency. " +
5752
"This recipe downloads and resolves the parent dependency's POM to determine its true transitive " +
5853
"dependencies, allowing it to detect redundancies even when both dependencies are explicitly declared.";
59-
}
6054

6155
@Value
6256
public static class Accumulator {

src/main/java/org/openrewrite/java/dependencies/UpgradeTransitiveDependencyVersion.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,12 @@
2525
@Value
2626
public class UpgradeTransitiveDependencyVersion extends ScanningRecipe<UpgradeTransitiveDependencyVersion.Accumulator> {
2727

28-
@Override
29-
public String getDisplayName() {
30-
return "Upgrade transitive Gradle or Maven dependencies";
31-
}
28+
String displayName = "Upgrade transitive Gradle or Maven dependencies";
3229

33-
@Override
34-
public String getDescription() {
35-
return "Upgrades the version of a transitive dependency in a Maven pom.xml or Gradle build.gradle. " +
30+
String description = "Upgrades the version of a transitive dependency in a Maven pom.xml or Gradle build.gradle. " +
3631
"Leaves direct dependencies unmodified. " +
3732
"Can be paired with the regular Upgrade Dependency Version recipe to upgrade a dependency everywhere, " +
3833
"regardless of whether it is direct or transitive.";
39-
}
4034

4135
@Option(displayName = "Group",
4236
description = "The first part of a dependency coordinate 'org.apache.logging.log4j:ARTIFACT_ID:VERSION'.",

src/main/java/org/openrewrite/java/dependencies/search/DoesNotIncludeDependency.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,10 @@
2323
@EqualsAndHashCode(callSuper = false)
2424
@Value
2525
public class DoesNotIncludeDependency extends Recipe {
26-
@Override
27-
public String getDisplayName() {
28-
return "Does not include dependency for Gradle and Maven";
29-
}
26+
String displayName = "Does not include dependency for Gradle and Maven";
3027

31-
@Override
32-
public String getDescription() {
33-
return "A precondition which returns false if visiting a Gradle file / Maven pom which includes the specified dependency in the classpath of some Gradle configuration / Maven scope. " +
28+
String description = "A precondition which returns false if visiting a Gradle file / Maven pom which includes the specified dependency in the classpath of some Gradle configuration / Maven scope. " +
3429
"For compatibility with multimodule projects, this should most often be applied as a precondition.";
35-
}
3630

3731
@Option(displayName = "Group",
3832
description = "The first part of a dependency coordinate `com.google.guava:guava:VERSION`. Supports glob.",

0 commit comments

Comments
 (0)