From f7e41edb947dad22e10eeaa2e68e6f44b4bfa747 Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Thu, 3 Sep 2015 23:57:38 +0200 Subject: [PATCH] Issue #2080: Replace ternary condition operator with if Fixes `ConditionalExpression` inspection violations. Description: >Reports the ternary condition operator. Some coding standards prohibit the use of the condition operator, in favor of if-else statements. --- config/intellij-idea-inspections.xml | 2 +- .../google/checkstyle/test/base/BaseCheckTestSupport.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/intellij-idea-inspections.xml b/config/intellij-idea-inspections.xml index d0d5e493d..a197a9299 100644 --- a/config/intellij-idea-inspections.xml +++ b/config/intellij-idea-inspections.xml @@ -367,7 +367,7 @@ - + diff --git a/src/it/java/com/google/checkstyle/test/base/BaseCheckTestSupport.java b/src/it/java/com/google/checkstyle/test/base/BaseCheckTestSupport.java index cd3387670..09fc5b09c 100644 --- a/src/it/java/com/google/checkstyle/test/base/BaseCheckTestSupport.java +++ b/src/it/java/com/google/checkstyle/test/base/BaseCheckTestSupport.java @@ -123,7 +123,10 @@ public abstract class BaseCheckTestSupport parseInt = parseInt.substring(parseInt.indexOf(':') + 1); parseInt = parseInt.substring(0, parseInt.indexOf(':')); int lineNumber = Integer.parseInt(parseInt); - Integer integer = Arrays.asList(aWarnsExpected).contains(lineNumber) ? lineNumber : 0; + Integer integer = 0; + if (Arrays.asList(aWarnsExpected).contains(lineNumber)) { + integer = lineNumber; + } assertEquals("error message " + i, (long) integer, lineNumber); }