ballerina:2 reports methods of an object constructor that initializes a typed class field
维护者通常 1 天内回复
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Java
- 星标
- 15
- 派生
- 12
- 平均合并
- 2 天 8 小时
- 30 天内合并 PR
- 29
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ballerina-platform/static-code-analysis-tool 的其他 Issue
-
Area/Configuration Type/Improvement
难度 2/5 1-3 小时 新手友好度 68/100
ballerina-platform/static-code-analysis-tool#217 ·
维护者通常 1 天内回复
-
Use the released ballerina/scan 1.0.0 on the 0.11.x line可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭Area/Build Type/Task
难度 1/5 1 小时以内 新手友好度 72/100
ballerina-platform/static-code-analysis-tool#200 · 1 条评论 ·
维护者通常 1 天内回复
-
Clarify the breaking location change and the password placeholder exception in the 0.14.0 changelog可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭Type/Docs
难度 1/5 1-3 小时 新手友好度 74/100
ballerina-platform/static-code-analysis-tool#198 · 2 条评论 ·
维护者通常 1 天内回复
-
Area/CLI Type/Improvement
难度 2/5 1-3 小时 新手友好度 68/100
ballerina-platform/static-code-analysis-tool#140 ·
维护者通常 1 天内回复
-
Area/Configuration Type/New Feature
难度 3/5 1-2 天 新手友好度 52/100
ballerina-platform/static-code-analysis-tool#211 ·
维护者通常 1 天内回复
查看 ballerina-platform/static-code-analysis-tool 的全部 Issue
相似的 Issue
-
vips-drift
难度 2/5 1-3 小时 新手友好度 74/100
Stirling-Tools/JPDFium#300 ·
维护者通常 1 天内回复
-
hermes-queue
难度 1/5 1-3 小时 新手友好度 85/100
chrisalunlloyd2-sudo/mindpalace#403 ·
维护者通常 1 天内回复
-
Guidelines: document how to build a use case against a local, unpublished Flow/browserless-test change可能已有人在做 @totally-not-ai 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 88/100
vaadin/use-cases#452 · 1 条评论 ·
维护者通常 1 天内回复
-
area/storage area/storage/sql
难度 2/5 1-3 小时 新手友好度 78/100
Apicurio/apicurio-registry#11159 ·
维护者通常 1 天内回复
-
triage
难度 2/5 1-3 小时 新手友好度 72/100
xerial/sqlite-jdbc#1515 ·
维护者通常 1 天内回复