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時間
- マージ済み PR(30日)
- 29
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン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対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン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
-
hermes-queue
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
chrisalunlloyd2-sudo/mindpalace#403 ·
メンテナーはふだん 1 日以内に返信
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
xerial/sqlite-jdbc#1515 ·
メンテナーはふだん 1 日以内に返信
-
SequenceEncoder: a value ending with a backslash swallows the tokens after it (“No state for trait”)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
vassalengine/vassal#15337 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
eclipse-dirigible/dirigible#8636 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug severity-medium XS
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
nikolas-charalambidis/facepalm-maven-plugin#291 ·
メンテナーはふだん 1 日以内に返信