mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge pull request #787 from hmakholm/pr/fix-useless-parameter
Fix false positives in java/unused parameter
This commit is contained in:
@@ -292,6 +292,10 @@ class RootdefCallable extends Callable {
|
||||
// a body that also doesn't.
|
||||
not hasUsefulBody(this) and
|
||||
not exists(Method m | hasUsefulBody(m) | m.overridesOrInstantiates+(this))
|
||||
or
|
||||
// Methods that are the target of a member reference need to implement
|
||||
// the exact signature of the resulting functional interface.
|
||||
exists(MemberRefExpr mre | mre.getReferencedCallable() = this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,10 @@ abstract class C implements I {
|
||||
}
|
||||
}
|
||||
|
||||
interface F {
|
||||
void doSomething(int arg2);
|
||||
}
|
||||
|
||||
public class Test {
|
||||
// OK: external interface
|
||||
public static void main(String[] args) {}
|
||||
@@ -54,6 +58,13 @@ public class Test {
|
||||
public static void foo(Object bar) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static F getF() {
|
||||
return Test::myFImplementation;
|
||||
}
|
||||
|
||||
// OK: mentioned in member reference
|
||||
private static void myFImplementation(int foo) {}
|
||||
|
||||
// OK: native method
|
||||
native int baz(int x);
|
||||
|
||||
Reference in New Issue
Block a user