ballerina:2 reports methods of an object constructor that initializes a typed class field
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 22/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Java
- Stelle
- 15
- Fork
- 12
- Merge medio
- 2g 8h
- PR unite (30g)
- 29
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ballerina-platform/static-code-analysis-tool
-
Area/Configuration Type/Improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ballerina-platform/static-code-analysis-tool#217 ·
I maintainer di solito rispondono entro 1 giorno
-
Use the released ballerina/scan 1.0.0 on the 0.11.x lineForse già presa Una pull request collegata a questa issue è aperta o già unita. ApertaArea/Build Type/Task
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
ballerina-platform/static-code-analysis-tool#200 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Clarify the breaking location change and the password placeholder exception in the 0.14.0 changelogForse già presa Una pull request collegata a questa issue è aperta o già unita. ApertaType/Docs
Difficoltà 1/5 1-3 ore Idoneità per principianti 74/100
ballerina-platform/static-code-analysis-tool#198 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Area/CLI Type/Improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ballerina-platform/static-code-analysis-tool#140 ·
I maintainer di solito rispondono entro 1 giorno
-
Area/Configuration Type/New Feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
ballerina-platform/static-code-analysis-tool#211 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ballerina-platform/static-code-analysis-tool
Issue simili
-
hermes-queue
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
chrisalunlloyd2-sudo/mindpalace#403 ·
I maintainer di solito rispondono entro 1 giorno
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
xerial/sqlite-jdbc#1515 ·
I maintainer di solito rispondono entro 1 giorno
-
SequenceEncoder: a value ending with a backslash swallows the tokens after it (“No state for trait”)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
vassalengine/vassal#15337 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
eclipse-dirigible/dirigible#8636 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug severity-medium XS
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
nikolas-charalambidis/facepalm-maven-plugin#291 ·
I maintainer di solito rispondono entro 1 giorno