You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A conditional return inside a code block (to exit out of the block) causes the plugin to crash and abort the scan.
I expect it is trying to match the return in the code block to the return of the method, which declares a return type.
To Reproduce
Steps to reproduce the behavior:
Create a Gosu class with a method that declares a return type.
Inside that method, execute a code block that tests some condition and does a return to skip to the next item in the .each() list.
In the method, return nothing
`public function isValid(pAccident : Accident, pOnlyErrors : boolean, pReportingPeriod : ReportingPeriod) : ArrayList {
var rir = new ArrayList()
var itemsIgnoredInBatchList = getItemIgnoredInBatchList(pReportingPeriod.StartDate)
register.eachKeyAndValue( \ code, item -> {
if (itemsIgnoredInBatchList.contains(code))
return
... more code here ...
})
return rir
`
See the error: Cannot invoke "de.friday.sonarqube.gosu.antlr.GosuParser$ExpressionContext.getText()" because "returnedValueContext" is null
Expected behavior
The scanner should see the return as an exit out of the .each() loop, not a return out of the function.
It would also be nice if the plugin reported the file it was working on when it aborts for whatever reason. :-)
Describe the bug
A conditional return inside a code block (to exit out of the block) causes the plugin to crash and abort the scan.
I expect it is trying to match the return in the code block to the return of the method, which declares a return type.
To Reproduce
Steps to reproduce the behavior:
Create a Gosu class with a method that declares a return type.
Inside that method, execute a code block that tests some condition and does a
return
to skip to the next item in the .each() list.In the method,
return
nothing`public function isValid(pAccident : Accident, pOnlyErrors : boolean, pReportingPeriod : ReportingPeriod) : ArrayList {
var rir = new ArrayList()
var itemsIgnoredInBatchList = getItemIgnoredInBatchList(pReportingPeriod.StartDate)
register.eachKeyAndValue( \ code, item -> {
if (itemsIgnoredInBatchList.contains(code))
return
... more code here ...
})
return rir
`
See the error:
Cannot invoke "de.friday.sonarqube.gosu.antlr.GosuParser$ExpressionContext.getText()" because "returnedValueContext" is null
Expected behavior
The scanner should see the return as an exit out of the .each() loop, not a return out of the function.
It would also be nice if the plugin reported the file it was working on when it aborts for whatever reason. :-)
Software Versions
Additional context
The text was updated successfully, but these errors were encountered: