mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Java: Exclude slf4j calls in PrintLnArray as it supports array formatting.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
| **Query** | **Expected impact** | **Change** |
|
||||
|----------------------------|------------------------|------------------------------------------------------------------|
|
||||
| Implicit conversion from array to string (`java/print-array`) | Fewer false positive results | Results in slf4j logging calls are no longer reported as slf4j supports array printing. |
|
||||
|
||||
## Changes to QL libraries
|
||||
|
||||
|
||||
@@ -27,7 +27,11 @@ predicate arraysToStringArgument(Expr e) {
|
||||
from Expr arr
|
||||
where
|
||||
arr.getType() instanceof Array and
|
||||
implicitToStringCall(arr)
|
||||
implicitToStringCall(arr) and
|
||||
not exists(FormattingCall fmtcall |
|
||||
// exclude slf4j formatting as it supports array formatting
|
||||
fmtcall.getAnArgumentToBeFormatted() = arr and fmtcall.getSyntax().isLogger()
|
||||
)
|
||||
or
|
||||
arr.getType().(Array).getComponentType() instanceof Array and
|
||||
arraysToStringArgument(arr)
|
||||
|
||||
@@ -85,6 +85,9 @@ class FmtSyntax extends TFmtSyntax {
|
||||
or
|
||||
result = "logger ({}) syntax" and this = TFmtLogger()
|
||||
}
|
||||
|
||||
/** Holds if this syntax is logger ({}) syntax. */
|
||||
predicate isLogger() { this = TFmtLogger() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user