question 2 en anglais
This commit is contained in:
@@ -4,3 +4,33 @@ Pick a Java project from Github (see the [instructions](../sujet.md) for suggest
|
|||||||
|
|
||||||
## Answer
|
## Answer
|
||||||
|
|
||||||
|
We clone the project `commons-math`
|
||||||
|
https://github.com/apache/commons-math
|
||||||
|
We found a problem that it's not worth to change
|
||||||
|
`./commons-math/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/AccurateMath.java:396: UselessParentheses: Useless parentheses around `0.5 * t`.`
|
||||||
|
And here is the code that PMD a indiqué:
|
||||||
|
```
|
||||||
|
if (x >= LOG_MAX_VALUE) {
|
||||||
|
// Avoid overflow (MATH-905).
|
||||||
|
final double t = exp(0.5 * x);
|
||||||
|
return (0.5 * t) * t;
|
||||||
|
```
|
||||||
|
|
||||||
|
As we can see the parentheses didn't cause any harm here but it is a true positive
|
||||||
|
|
||||||
|
For a false positive, we found this one:
|
||||||
|
`./commons-math/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/IntegerSequenceTest.java:255: UnusedLocalVariable: Avoid unused local variables such as 'inc'.`
|
||||||
|
|
||||||
|
```
|
||||||
|
@Test(expected = ZeroException.class)
|
||||||
|
public void testIncrementZeroStep() {
|
||||||
|
final int step = 0;
|
||||||
|
|
||||||
|
final IntegerSequence.Incrementor inc
|
||||||
|
= IntegerSequence.Incrementor.create()
|
||||||
|
.withIncrement(step);
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Because the purpose of the test is to trigger the bug when create object.
|
||||||
Reference in New Issue
Block a user