This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git

commit 322245cc81e28e101a5c559588c7acc949c017fc
Author: aherbert <aherb...@apache.org>
AuthorDate: Mon Jun 29 15:20:03 2020 +0100

    Fix SonarCloud: Extract nested ternary
---
 .../commons/statistics/distribution/TDistribution.java    | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TDistribution.java
 
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TDistribution.java
index ad7165d..0b9627f 100644
--- 
a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TDistribution.java
+++ 
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TDistribution.java
@@ -51,11 +51,16 @@ public class TDistribution extends 
AbstractContinuousDistribution {
         factor = LogGamma.value(dofOver2 + 0.5) -
                  0.5 * (Math.log(Math.PI) + Math.log(degreesOfFreedom)) -
                  LogGamma.value(dofOver2);
-        mean = degreesOfFreedom > 1 ? 0 :
-            Double.NaN;
-        variance = degreesOfFreedom > 2 ? degreesOfFreedom / (degreesOfFreedom 
- 2) :
-            degreesOfFreedom > 1 ? Double.POSITIVE_INFINITY :
-            Double.NaN;
+        if (degreesOfFreedom > 2) {
+            mean = 0;
+            variance = degreesOfFreedom / (degreesOfFreedom - 2);
+        } else if (degreesOfFreedom > 1) {
+            mean = 0;
+            variance = Double.POSITIVE_INFINITY;
+        } else {
+            mean = Double.NaN;
+            variance = Double.NaN;
+        }
     }
 
     /**

Reply via email to