From d49eaaf2e42538bc7f01510eb3ca2812b253c98a Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Sun, 2 Aug 2015 15:34:39 +0200 Subject: [PATCH] Extract increment operations to separate expressions. #1538 While increment or decrement expressions nested inside other expressions are admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing. --- .../java/com/puppycrawl/tools/checkstyle/api/FileText.java | 3 ++- .../tools/checkstyle/checks/DescendantTokenCheck.java | 3 ++- .../tools/checkstyle/checks/indentation/HandlerFactory.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/api/FileText.java b/src/main/java/com/puppycrawl/tools/checkstyle/api/FileText.java index a834caab6..53ac44685 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/FileText.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/FileText.java @@ -252,7 +252,8 @@ public final class FileText extends AbstractList { int lineNo = 1; final Matcher matcher = LINE_TERMINATOR.matcher(fullText); while (matcher.find()) { - lineBreaks[lineNo++] = matcher.end(); + lineBreaks[lineNo] = matcher.end(); + lineNo++; } if (lineNo < lineBreaks.length) { lineBreaks[lineNo] = fullText.length(); diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheck.java index b7d1552b6..02193e53b 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheck.java @@ -327,7 +327,8 @@ public class DescendantTokenCheck extends Check { final int[] result = new int[tokenNames.size()]; int i = 0; for (String name : tokenNames) { - result[i++] = Utils.getTokenId(name); + result[i] = Utils.getTokenId(name); + i++; } return result; } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java index 979eaef74..9a46da6aa 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java @@ -115,7 +115,8 @@ public class HandlerFactory { final int[] types = new int[typeSet.size()]; int index = 0; for (final Integer val : typeSet) { - types[index++] = val; + types[index] = val; + index++; } return types;