redhat-developer / redhat-developer/vscode-java

Editor erroneously reports warning in conditional operator

Đang mở
#821 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug diagnostics upstream
Ngôn ngữ chính
TypeScript
Star
2.3k
Fork
546
Merge trung bình
20 giờ 1 phút
Pull request đã merge (30 ngày)
11

Mô tả

Erroneous warnings are reported in the editor in conditional operators.

Environment
  • Operating System: Windows 10 Pro
  • JDK version: OpenJDK 11.0.1
  • Visual Studio Code version: 1.30.1
  • Java extension version: 0.40.0
Steps To Reproduce

Write code like the following:

SpeedController motor;
if (RobotMap.isCompetitionRobot)
{
	motor = new WPI_TalonSRX(RobotMap.liftMotorCanDeviceId);
}
else
{
	motor = new Spark(RobotMap.centerLegMotorPwmChannel);
}
		
motor = RobotMap.isCompetitionRobot
	? new WPI_TalonSRX(RobotMap.liftMotorCanDeviceId)
	: new Spark(RobotMap.centerLegMotorPwmChannel);

where the class Spark extends a class that implements AutoCloseable.

Current Result

No warnings are reported in the if statement. However, the warning:

Resource leak: '<unassigned Closeable value>' is never closed

is reported for the code:

new Spark(RobotMap.centerLegMotorPwmChannel)

in the conditional operator.

Expected Result

No warnings should be reported at all.

Additional Informations

None.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện cảnh báo với ví dụ về toán tử điều kiện trong issue, sử dụng các phiên bản Windows, JDK, VS Code và Java extension được liệt kê khi có thể. Theo dõi quá trình phân tích rò rỉ tài nguyên của Java extension đối với các biểu thức điều kiện. Được xem là hoàn tất khi biểu thức điều kiện không tạo ra cảnh báo sai nào, trong khi hành vi của câu lệnh if hiện có vẫn không thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.