Skip to content

Commit ea8167f

Browse files
refactor: Enum values should be compared with "=="
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.CompareEnumsWithEqualityOperator?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne <[email protected]>
1 parent 3425b85 commit ea8167f

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/main/java/org/openrewrite/java/migrate/javax/AddJaxwsRuntime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public Xml.Document visitDocument(Xml.Document document, ExecutionContext ctx) {
231231
for (ResolvedDependency dependency : entry.getValue()) {
232232
if (groupId.equals(dependency.getGroupId()) && artifactId.equals(dependency.getArtifactId())) {
233233
maxScope = Scope.maxPrecedence(maxScope, entry.getKey());
234-
if (Scope.Compile.equals(maxScope)) {
234+
if (Scope.Compile == maxScope) {
235235
return maxScope;
236236
}
237237
break;

src/main/java/org/openrewrite/java/migrate/lang/var/DeclarationCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private static boolean isSingleVariableDefinition(J.VariableDeclarations vd) {
5555
TypeTree typeExpression = vd.getTypeExpression();
5656

5757
boolean definesSingleVariable = vd.getVariables().size() == 1;
58-
boolean isPureAssigment = JavaType.Primitive.Null.equals(vd.getType());
58+
boolean isPureAssigment = JavaType.Primitive.Null == vd.getType();
5959
if (!definesSingleVariable || isPureAssigment) {
6060
return false;
6161
}

src/main/java/org/openrewrite/java/migrate/lang/var/UseVarForPrimitive.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ private Expression expandWithPrimitivTypeHint(J.VariableDeclarations vd, Express
117117
return initializer;
118118
}
119119

120-
boolean isLongLiteral = JavaType.Primitive.Long.equals(vd.getType());
120+
boolean isLongLiteral = JavaType.Primitive.Long == vd.getType();
121121
boolean inferredAsLong = valueSource.endsWith("l") || valueSource.endsWith("L");
122-
boolean isFloatLiteral = JavaType.Primitive.Float.equals(vd.getType());
122+
boolean isFloatLiteral = JavaType.Primitive.Float == vd.getType();
123123
boolean inferredAsFloat = valueSource.endsWith("f") || valueSource.endsWith("F");
124-
boolean isDoubleLiteral = JavaType.Primitive.Double.equals(vd.getType());
124+
boolean isDoubleLiteral = JavaType.Primitive.Double == vd.getType();
125125
boolean inferredAsDouble = valueSource.endsWith("d") || valueSource.endsWith("D") || valueSource.contains(".");
126126

127127
String typNotation = null;

src/main/java/org/openrewrite/java/migrate/lombok/LombokValueToRecord.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
117117
private boolean isRelevantClass(J.ClassDeclaration classDeclaration) {
118118
List<J.Annotation> allAnnotations = classDeclaration.getAllAnnotations();
119119
return classDeclaration.getType() != null &&
120-
!J.ClassDeclaration.Kind.Type.Record.equals(classDeclaration.getKind()) &&
120+
J.ClassDeclaration.Kind.Type.Record != classDeclaration.getKind() &&
121121
hasMatchingAnnotations(classDeclaration) &&
122122
!hasGenericTypeParameter(classDeclaration) &&
123123
classDeclaration.getBody().getStatements().stream().allMatch(this::isRecordCompatibleField) &&

0 commit comments

Comments
 (0)