Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore method invocation arguments that are not string J.Literals #4276

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Ignore method invocation arguments that are not string J.Literals
Fixes: #4275
Jente Sondervorst committed Jun 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit ba6db7a9766121cc9003cf865da760eec571b122
Original file line number Diff line number Diff line change
@@ -435,6 +435,9 @@ private J.MethodInvocation updateDependency(J.MethodInvocation method, Execution
}
} else if (arg instanceof J.Literal) {
J.Literal literal = (J.Literal) arg;
if (literal.getType() != JavaType.Primitive.String) {
return arg;
}
String gav = (String) literal.getValue();
if (gav == null) {
getCursor().putMessage(UPDATE_VERSION_ERROR_KEY, new IllegalStateException("Unable to update version"));
Original file line number Diff line number Diff line change
@@ -882,4 +882,29 @@ void unknownConfiguration() {
)
);
}

@Test
@Issue("https://github.com/openrewrite/rewrite/issues/4275")
void noActionForNonStringLiterals() {
rewriteRun(
buildGradle(
"""
plugins {
id 'java'
}

repositories {
mavenCentral()
}

dependencies {
implementation(gradleApi())
jar {
enabled(true)
}
}
"""
)
);
}
}