Merge pull request #9120 from igfoo/igfoo/fixes

Kotlin: Fix some alerts
This commit is contained in:
Anders Schack-Mulligen
2022-05-12 08:29:34 +02:00
committed by GitHub
3 changed files with 6 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import java
import semmle.code.configfiles.ConfigFiles
import semmle.code.java.Diagnostics
// Locations should either be :0:0:0:0 locations (UnknownLocation, or
// a whole file), or all 4 fields should be positive.
@@ -27,7 +28,7 @@ Location unusedLocation() {
not exists(Top t | t.getLocation() = result) and
not exists(XMLLocatable x | x.getLocation() = result) and
not exists(ConfigLocatable c | c.getLocation() = result) and
not exists(@diagnostic d | diagnostics(d, _, _, _, _, _, result)) and
not exists(Diagnostic d | d.getLocation() = result) and
not (
result.getFile().getExtension() = "xml" and
result.getStartLine() = 0 and

View File

@@ -1374,10 +1374,10 @@ class LambdaExpr extends FunctionalExpr, @lambdaexpr {
* The parameters of the lambda expression are the parameters of this method.
*/
override Method asMethod() {
not isKotlinFunctionN() and
not this.isKotlinFunctionN() and
result = this.getAnonymousClass().getAMethod()
or
isKotlinFunctionN() and
this.isKotlinFunctionN() and
result = this.getAnonymousClass().getAMethod() and
result.getNumberOfParameters() > 1
}
@@ -1644,7 +1644,7 @@ class NotInstanceOfExpr extends Expr, @notinstanceofexpr {
Expr getTypeName() { result.isNthChildOf(this, 1) }
/** Gets the type this `!is` expression checks for. */
RefType getCheckedType() { result = getTypeName().getType() }
RefType getCheckedType() { result = this.getTypeName().getType() }
/** Gets a printable representation of this expression. */
override string toString() { result = "... !is ..." }

View File

@@ -91,7 +91,7 @@ class Parameter extends Element, @param, LocalScopeVariable {
/** Holds if this formal parameter is a parameter representing the dispatch receiver in an extension method. */
predicate isExtensionParameter() {
getPosition() = 0 and this.getCallable() instanceof ExtensionMethod
this.getPosition() = 0 and this.getCallable() instanceof ExtensionMethod
}
/**