mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Kotlin: Fix some alerts
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 ..." }
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user