`AddMissingMethodImplementation` generates wrong method for constructors
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu với bản tái hiện AddMissingMethodImplementationTest được cung cấp và kiểm tra AddMissingMethodImplementation để xem các mẫu phương thức constructor được kết xuất như thế nào. Chạy bài kiểm thử được tham số hóa cho cả hai mẫu phương thức; hoàn tất khi constructor được tạo có tên là ImplementationClass, không có kiểu trả về Template không chính xác và khớp với mã dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What version of OpenRewrite are you using?
I am using
- OpenRewrite v8.9.4
- Maven/Gradle plugin RELEASE
- rewrite-migrate-java v2.3.0
How are you running OpenRewrite?
I'm applying rules using the maven plugin and a custom recipe artifact
What is the smallest, simplest way to reproduce the problem?
package org.openrewrite.java.migrate;
import org.intellij.lang.annotations.Language;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RewriteTest;
import static org.openrewrite.java.Assertions.java;
class AddMissingMethodImplementationTest implements RewriteTest {
@ParameterizedTest
@ValueSource(strings = {
"*..* <constructor>(String)",
"org.openrewrite.example.ImplementationClass <constructor>(String)",
})
void addMissingConstructor(String methodPattern) {
@Language("java")
final String abstractClassTemplate = """
package org.openrewrite.example;
public abstract class AbstractClass {
private final String param;
protected AbstractClass(String param) {
this.param = param;
}
public String getParam() {
return param;
}
}
""";
@Language("java")
final String originalClass = """
package org.openrewrite.example;
public class ImplementationClass extends AbstractClass {
}
""";
@Language("java")
final String expected = """
package org.openrewrite.example;
public class ImplementationClass extends AbstractClass {
public ImplementationClass(String param) {
super(param);
}
}
""";
rewriteRun(
spec -> spec
.parser(JavaParser.fromJavaVersion().dependsOn(abstractClassTemplate))
.recipe(new AddMissingMethodImplementation(
"org.openrewrite.example.AbstractClass",
methodPattern,
"""
public ImplementationClass(String param) {
super(param);
}"""
)),
java(originalClass, expected)
);
}
}
What did you expect to see?
package org.openrewrite.example;
public class ImplementationClass extends AbstractClass {
public ImplementationClass(String param) {
super(param);
}
}
What did you see instead?
package org.openrewrite.example;
public class ImplementationClass extends AbstractClass {
- public ImplementationClass(String param) {
+ public Template ImplementationClass(String param) {
super(param);
}
}
What is the full stack trace of any errors you encountered?
recipe completes successfully
Are you interested in contributing a fix to OpenRewrite?
- Ngôn ngữ chính
- Java
- Star
- 156
- Fork
- 129
- Merge trung bình
- 3 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openrewrite/rewrite-migrate-java
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
openrewrite/rewrite-migrate-java#1246 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
openrewrite/rewrite-migrate-java#1228 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 32/100
openrewrite/rewrite-migrate-java#1227 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
openrewrite/rewrite-migrate-java#1146 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
openrewrite/rewrite-migrate-java#1119 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của openrewrite/rewrite-migrate-java
Issue tương tự
-
area/frontend good first issue kind/cooldown
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
beehive-lab/TornadoVM#1151 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
(cbor) `maxStringLength` not consistently checked for chunked (indefinite-length) text valuesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
FasterXML/jackson-dataformats-binary#823 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày