ballerina:2 reports methods of an object constructor that initializes a typed class field
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 22/100
Hướng nghiên cứu
Start with StaticCodeAnalyzer.contextualTypes, which has no case for ObjectFieldNode and falls back to semanticModel.expectedType. Run bal scan field.bal on the reproduction in the issue to confirm that line 7 is reported and line 12 is not. Done means the class-field object constructor is no longer flagged while the existing rule tests still pass. Pull request #204 is already open against this issue, so check it before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Area
Rules
Description
ballerina:2 should not report the parameters of methods that implement a method of the type of an object constructor (#169, #173 and the 0.11.x backport #182). When the object constructor initializes a typed class field, the parameter is still reported. The same constructor, typed by the same object type, is not reported as a module variable, local variable, return value, argument, assignment, record field or expression body. An anonymous function in a class field initializer (final BinOp f = function(int a, int b) ...) is not reported either.
Likely cause, from reading the source (not verified): StaticCodeAnalyzer.contextualTypes has no case for ObjectFieldNode and falls back to semanticModel.expectedType(document, startLine), which does not give the field's type for an object constructor.
Found while testing v0.14.0 (#186) and v0.11.2 (#187).
Steps to Reproduce
field.bal:
type Op object {
function m(int p) returns int;
};
class Holder {
final Op viaField = object {
function m(int p) returns int => 1;
};
}
Op viaModule = object {
function m(int p) returns int => 1;
};
public function main() {
_ = new Holder();
_ = viaModule;
}
Run bal scan field.bal.
Expected Behavior
No issues: both m methods implement Op.m, so their signatures are fixed by the type.
Actual Output
[('ballerina:2', 7)]
Line 7 (the class field) is reported; line 12 (the module variable) is not.
Ballerina Version
2201.12.0 (scan 0.11.2); 2201.13.2 and 2201.14.1 (scan 0.14.0)
Scan Tool Version
0.14.0 and 0.11.2 (DEV Central)
Environment
macOS
- Ngôn ngữ chính
- Java
- Star
- 15
- Fork
- 12
- Merge trung bình
- 2 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 29
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không 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 ballerina-platform/static-code-analysis-tool
-
Area/Configuration Type/Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ballerina-platform/static-code-analysis-tool#217 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Use the released ballerina/scan 1.0.0 on the 0.11.x lineCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởArea/Build Type/Task
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
ballerina-platform/static-code-analysis-tool#200 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Clarify the breaking location change and the password placeholder exception in the 0.14.0 changelogCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởType/Docs
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 74/100
ballerina-platform/static-code-analysis-tool#198 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Area/CLI Type/Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ballerina-platform/static-code-analysis-tool#140 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Area/Configuration Type/New Feature
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
ballerina-platform/static-code-analysis-tool#211 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ballerina-platform/static-code-analysis-tool
Issue tương tự
-
hermes-queue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
chrisalunlloyd2-sudo/mindpalace#403 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
xerial/sqlite-jdbc#1515 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SequenceEncoder: a value ending with a backslash swallows the tokens after it (“No state for trait”)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
vassalengine/vassal#15337 ·
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 76/100
eclipse-dirigible/dirigible#8636 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug severity-medium XS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
nikolas-charalambidis/facepalm-maven-plugin#291 ·
Maintainer thường phản hồi trong vòng 1 ngày