openrewrite / openrewrite/rewrite
GroovyParser should not report a warning when setting a writable property
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
What version of OpenRewrite are you using?
- OpenRewrite v8.43.1
How are you running OpenRewrite?
As a test that implements RecipeTest executed by Gradle. I also added a logging library to my test execution classpath.
testRuntimeOnly("org.slf4j:slf4j-simple:2.0.16")
What is the smallest, simplest way to reproduce the problem?
Write a custom recipe that generate a Gradle build file, along the lines of the following:
private SourceFile generateBuildFile(ExecutionContext ctx) {
String buildFileContent = """
plugins {
id 'java'
}
version = '1.2.3'
""";
return GradleParser.builder().build()
.parseInputs(singletonList(Parser.Input.fromString(Paths.get("build.gradle"), buildFileContent)), null, ctx)
.findFirst().get();
}
What did you expect to see?
No warning from the Groovy parser. The property Project.version has a setter method.
What did you see instead?
The following output when executing the test with Gradle.
[Test worker] WARN org.openrewrite.groovy.GroovyParser - doesntmatter: 5: [Static type checking] - Cannot set read-only property: version
@ line 5, column 1.
version = '1.2.3'
^
1 error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning with the custom RecipeTest and GradleParser input shown in the issue, then start by tracing GroovyParser handling of the version = '1.2.3' assignment. Confirm the fix by running the test with the generated Gradle build file and verifying that no read-only-property warning is emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100