Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
(VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED)
A format-string method with a variable number of arguments is called, but more arguments are passed than are actually used by the format string. This won't cause a runtime exception, but the code may be silently omitting information that was intended to be included in the formatted string.
When is used the method Format to insert values of the variables in a string, is possible that the number of arguments doesn't fit with the number of variables fixed in the string. Therefore, this inconsistency will only be seen in the moment that is executed the method.
Add here a minimal example where the problem occurs. It should be possible to use this code for testing our analysis: <code Java>
String StringVar = String.format(“The value of the float variable is %f, while the value of the integer variable is %d”,floatVar);
</Code>
<code Java>
String StringVar = String.format(“The value of the float variable is %f, while the value of the integer variable is %d”,floatVar,integerVar);
</Code>
<code Java>
String StringVar = String.format(“The number of variables is decision of the programmer, therefore one sample fix could be let the without extra parameters”);
</Code>
Benchmark project | Precision | Recall | ||||
---|---|---|---|---|---|---|
FB | JT | Delta | FB | JT | Delta | |
Project … | …% | …% | …% | …% | …% | …% |
Project … | …% | …% | …% | …% | …% | …% |
FB = FindBugs, JT = JTransformer, Delta = JTransformer - FindBugs