Java: Exclude slf4j calls in PrintLnArray as it supports array formatting.

This commit is contained in:
Anders Schack-Mulligen
2019-04-04 11:01:00 +02:00
parent b226cb64cd
commit d144ea2f1c
3 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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() }
}
/**