mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
Java: Enchanced isWithinType to also include lambdas, inner classes etc.
This commit is contained in:
@@ -15,9 +15,13 @@
|
||||
import java
|
||||
|
||||
/**
|
||||
* A `Callable` is within some `RefType`
|
||||
* A `Callable` is within some `RefType` (including through lambdas and inner classes)
|
||||
*/
|
||||
predicate isWithinType(Callable c, RefType t) { c.getDeclaringType() = t }
|
||||
predicate isWithinType(Callable c, RefType t) {
|
||||
c.getDeclaringType() = t
|
||||
or
|
||||
c.getDeclaringType().getEnclosingType*() = t
|
||||
}
|
||||
|
||||
/**
|
||||
* A `Callable` is within same package as the `RefType`
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
| packageone/SourcePackage.java:26:31:26:42 | Annotated.m2 | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:11:26:11:27 | m2 | element |
|
||||
| packageone/SourcePackage.java:29:28:29:46 | fPublic(...) | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:26:23:26:29 | fPublic | element |
|
||||
| packageone/SourcePackage.java:30:28:30:49 | fProtected(...) | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:31:26:31:35 | fProtected | element |
|
||||
| packagetwo/Annotated.java:49:31:49:31 | m | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:7:19:7:19 | m | element |
|
||||
| packagetwo/Annotated.java:54:26:54:28 | f(...) | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:16:16:16:16 | f | element |
|
||||
| packagetwo/Annotated.java:64:28:64:28 | m | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:7:19:7:19 | m | element |
|
||||
| packagetwo/Annotated.java:69:26:69:28 | f(...) | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:16:16:16:16 | f | element |
|
||||
| packagetwo/Source.java:8:20:8:30 | Annotated.m | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:7:19:7:19 | m | element |
|
||||
| packagetwo/Source.java:14:17:14:29 | f(...) | Access of $@ annotated with VisibleForTesting found in production code. | packagetwo/Annotated.java:16:16:16:16 | f | element |
|
||||
| packagetwo/Source.java:20:28:20:47 | new AnnotatedClass(...) | Access of $@ annotated with VisibleForTesting found in production code. | packageone/AnnotatedClass.java:4:14:4:27 | AnnotatedClass | element |
|
||||
|
||||
@@ -46,12 +46,12 @@ public class Annotated {
|
||||
|
||||
private static void resetPriorities2() {
|
||||
Runnable task = () -> {
|
||||
String priority = m; // $ SPURIOUS: Alert
|
||||
String priority = m;
|
||||
String priority1 = m1;
|
||||
String priority2 = m2;
|
||||
String priority3 = m3;
|
||||
|
||||
int result = f(); // $ SPURIOUS: Alert
|
||||
int result = f();
|
||||
int resultPrivate = fPrivate();
|
||||
int resultPublic = fPublic();
|
||||
int resultProtected = fProtected();
|
||||
@@ -61,12 +61,12 @@ public class Annotated {
|
||||
|
||||
private static class InnerClass {
|
||||
void useVisibleForMembers() {
|
||||
String field = m; // $ SPURIOUS: Alert
|
||||
String field = m;
|
||||
String field1 = m1;
|
||||
String field2 = m2;
|
||||
String field3 = m3;
|
||||
|
||||
int method = f(); // $ SPURIOUS: Alert
|
||||
int method = f();
|
||||
int methodPrivate = fPrivate();
|
||||
int methodPublic = fPublic();
|
||||
int methodProtected = fProtected();
|
||||
|
||||
Reference in New Issue
Block a user