Skip to content

Commit 6eca13a

Browse files
timtebeekTeamModerne
authored andcommitted
1 parent 8e44876 commit 6eca13a

10 files changed

+14
-14
lines changed

src/main/java/org/openrewrite/staticanalysis/ChainStringBuilderAppendCalls.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
9494
appendToString = true;
9595
} else if ((exp instanceof J.Identifier || exp instanceof J.MethodInvocation) && exp.getType() != null) {
9696
JavaType.FullyQualified fullyQualified = TypeUtils.asFullyQualified(exp.getType());
97-
if (fullyQualified != null && fullyQualified.getFullyQualifiedName().equals("java.lang.String")) {
97+
if (fullyQualified != null && "java.lang.String".equals(fullyQualified.getFullyQualifiedName())) {
9898
addToGroups(group, groups);
9999
appendToString = true;
100100
}

src/main/java/org/openrewrite/staticanalysis/DefaultComesLastVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private boolean isDefaultCaseLastOrNotPresent(J.Switch switch_) {
214214

215215
private boolean isDefaultCase(J.Case case_) {
216216
J elem = case_.getCaseLabels().get(0);
217-
return elem instanceof J.Identifier && ((J.Identifier) elem).getSimpleName().equals("default");
217+
return elem instanceof J.Identifier && "default".equals(((J.Identifier) elem).getSimpleName());
218218
}
219219

220220
}

src/main/java/org/openrewrite/staticanalysis/ExplicitLambdaArgumentTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private J.VariableDeclarations maybeAddTypeExpression(J.VariableDeclarations mul
189189
if (type instanceof JavaType.GenericTypeVariable) {
190190
JavaType.GenericTypeVariable genericType = (JavaType.GenericTypeVariable) type;
191191

192-
if (!genericType.getName().equals("?")) {
192+
if (!"?".equals(genericType.getName())) {
193193
return new J.Identifier(Tree.randomId(),
194194
space,
195195
Markers.EMPTY,

src/main/java/org/openrewrite/staticanalysis/JavaElementFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ static J.MemberReference newInstanceMethodReference(Expression containing, Strin
144144
private static JavaType.@Nullable Class getClassType(@Nullable JavaType type) {
145145
if (type instanceof JavaType.Class) {
146146
JavaType.Class classType = (JavaType.Class) type;
147-
if (classType.getFullyQualifiedName().equals("java.lang.Class")) {
147+
if ("java.lang.Class".equals(classType.getFullyQualifiedName())) {
148148
return classType;
149149
}
150-
if (classType.getFullyQualifiedName().equals("java.lang.Object")) {
150+
if ("java.lang.Object".equals(classType.getFullyQualifiedName())) {
151151
for (JavaType.Method method : classType.getMethods()) {
152-
if (method.getName().equals("getClass")) {
152+
if ("getClass".equals(method.getName())) {
153153
return getClassType(method.getReturnType());
154154
}
155155
}

src/main/java/org/openrewrite/staticanalysis/MinimumSwitchCases.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private List<Statement> getStatements(J.Case aCase) {
242242
}
243243

244244
private boolean isDefault(J.Case case_) {
245-
return case_.getPattern() instanceof J.Identifier && ((J.Identifier) case_.getPattern()).getSimpleName().equals("default");
245+
return case_.getPattern() instanceof J.Identifier && "default".equals(((J.Identifier) case_.getPattern()).getSimpleName());
246246
}
247247

248248
private boolean switchesOnEnum(J.Switch switch_) {

src/main/java/org/openrewrite/staticanalysis/ReplaceClassIsInstanceWithInstanceof.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private J mapInstanceOf(J tree, Function<J.InstanceOf, J.InstanceOf> fun) {
9595
private boolean isObjectClass(@Nullable Expression expression) {
9696
if (expression instanceof J.FieldAccess) {
9797
J.FieldAccess fieldAccess = (J.FieldAccess) expression;
98-
if (fieldAccess.getName().getSimpleName().equals("class") && fieldAccess.getTarget() instanceof Identifier) {
98+
if ("class".equals(fieldAccess.getName().getSimpleName()) && fieldAccess.getTarget() instanceof Identifier) {
9999
Identifier identifier = (Identifier) fieldAccess.getTarget();
100100
return identifier.getType() instanceof JavaType.Class;
101101
}

src/main/java/org/openrewrite/staticanalysis/ReplaceLambdaWithMethodReference.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public J visitLambda(J.Lambda lambda, ExecutionContext ctx) {
100100
if (classLiteral != null) {
101101
//noinspection DataFlowIssue
102102
JavaType.FullyQualified rawClassType = ((JavaType.Parameterized) classLiteral.getType()).getType();
103-
Optional<JavaType.Method> isInstanceMethod = rawClassType.getMethods().stream().filter(m -> m.getName().equals("isInstance")).findFirst();
103+
Optional<JavaType.Method> isInstanceMethod = rawClassType.getMethods().stream().filter(m -> "isInstance".equals(m.getName())).findFirst();
104104
if (isInstanceMethod.isPresent()) {
105105
J.MemberReference updated = newInstanceMethodReference(classLiteral, isInstanceMethod.get(), lambda.getType()).withPrefix(lambda.getPrefix());
106106
doAfterVisit(service(ImportService.class).shortenFullyQualifiedTypeReferencesIn(updated));
@@ -123,7 +123,7 @@ public J visitLambda(J.Lambda lambda, ExecutionContext ctx) {
123123
if (classLiteral != null) {
124124
//noinspection DataFlowIssue
125125
JavaType.FullyQualified classType = ((JavaType.Parameterized) classLiteral.getType()).getType();
126-
Optional<JavaType.Method> castMethod = classType.getMethods().stream().filter(m -> m.getName().equals("cast")).findFirst();
126+
Optional<JavaType.Method> castMethod = classType.getMethods().stream().filter(m -> "cast".equals(m.getName())).findFirst();
127127
if (castMethod.isPresent()) {
128128
J.MemberReference updated = newInstanceMethodReference(classLiteral, castMethod.get(), lambda.getType()).withPrefix(lambda.getPrefix());
129129
doAfterVisit(service(ImportService.class).shortenFullyQualifiedTypeReferencesIn(updated));
@@ -323,7 +323,7 @@ private boolean isNullCheck(J j1, J j2) {
323323
private boolean isMethodReferenceAmbiguous(JavaType.Method method) {
324324
int count = 0;
325325
for (JavaType.Method meth : method.getDeclaringType().getMethods()) {
326-
if (meth.getName().equals(method.getName()) && !meth.getName().equals("println") && !meth.isConstructor()) {
326+
if (meth.getName().equals(method.getName()) && !"println".equals(meth.getName()) && !meth.isConstructor()) {
327327
if (++count > 1) {
328328
return true;
329329
}

src/main/java/org/openrewrite/staticanalysis/TernaryOperatorsShouldNotBeNested.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private Optional<J.Identifier> findConditionIdentifier(final J.Ternary ternary)
279279
J.Identifier result = null;
280280
if (ternary.getCondition() instanceof J.MethodInvocation) {
281281
J.MethodInvocation inv = (J.MethodInvocation) ternary.getCondition();
282-
if (!inv.getSimpleName().equals("equals")) {
282+
if (!"equals".equals(inv.getSimpleName())) {
283283
return Optional.empty();
284284
}
285285
if (inv.getArguments().size() == 1) {

src/main/java/org/openrewrite/staticanalysis/UnnecessaryExplicitTypeArguments.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
8686
}
8787
inferredType = ((NameTree) enclosing).getType();
8888
} else if (enclosing instanceof J.Return) {
89-
Object e = getCursor().dropParentUntil(p -> p instanceof J.MethodDeclaration || p instanceof J.Lambda || p.equals(Cursor.ROOT_VALUE)).getValue();
89+
Object e = getCursor().dropParentUntil(p -> p instanceof J.MethodDeclaration || p instanceof J.Lambda || Cursor.ROOT_VALUE.equals(p)).getValue();
9090
if (e instanceof J.MethodDeclaration) {
9191
J.MethodDeclaration methodDeclaration = (J.MethodDeclaration) e;
9292
if (methodDeclaration.getReturnTypeExpression() != null) {

src/main/java/org/openrewrite/staticanalysis/UseLambdaForFunctionalInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private static boolean usesThis(Cursor cursor) {
258258
new JavaVisitor<Integer>() {
259259
@Override
260260
public J visitIdentifier(J.Identifier ident, Integer integer) {
261-
if (ident.getSimpleName().equals("this")) {
261+
if ("this".equals(ident.getSimpleName())) {
262262
hasThis.set(true);
263263
}
264264
return super.visitIdentifier(ident, integer);

0 commit comments

Comments
 (0)