From d86329ca8fe253b7b830b77595944d99a7ed4cfd Mon Sep 17 00:00:00 2001 From: Oliver Burn Date: Fri, 30 Aug 2013 16:32:31 +1000 Subject: [PATCH] Make the tests pass Fix Checkstyle errors --- .../whitespace/GenericWhitespaceCheck.java | 27 +++++++++---------- .../filters/SuppressionsLoaderTest.java | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheck.java index 424974974..5fe44d7b4 100755 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheck.java @@ -114,19 +114,19 @@ public class GenericWhitespaceCheck extends Check // ^ // should be whitespace if followed by & -+ // - int indexOfAmp = line.indexOf('&', after); - if ((indexOfAmp != -1) && whitespaceBetween(after, indexOfAmp, line)) + final int indexOfAmp = line.indexOf('&', after); + if ((indexOfAmp != -1) + && whitespaceBetween(after, indexOfAmp, line)) { - if (indexOfAmp - after == 0) - { + if (indexOfAmp - after == 0) { log(aAST.getLineNo(), after, "ws.notPreceded", "&"); } - else if (indexOfAmp - after != 1) - { + else if (indexOfAmp - after != 1) { log(aAST.getLineNo(), after, "ws.followed", ">"); } } - else if ((line.charAt(after) != '>') && (line.charAt(after) != ',')) + else if ((line.charAt(after) != '>') + && (line.charAt(after) != ',')) { log(aAST.getLineNo(), after, "ws.followed", ">"); } @@ -182,17 +182,16 @@ public class GenericWhitespaceCheck extends Check * Returns whether the specified string contains only whitespace between * specified indices. * - * @param fromIndex the index to start the search from. Inclusive - * @param toIndex the index to finish the search. Exclusive + * @param aFromIndex the index to start the search from. Inclusive + * @param aToIndex the index to finish the search. Exclusive * @param aLine the line to check * @return whether there are only whitespaces (or nothing) */ - private static boolean whitespaceBetween(int fromIndex, int toIndex, String aLine) + private static boolean whitespaceBetween( + int aFromIndex, int aToIndex, String aLine) { - for (int i = fromIndex; i < toIndex; i++) - { - if (!Character.isWhitespace(aLine.charAt(i))) - { + for (int i = aFromIndex; i < aToIndex; i++) { + if (!Character.isWhitespace(aLine.charAt(i))) { return false; } } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java b/src/tests/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java index 83f34a2bd..c25c9cf29 100755 --- a/src/tests/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java @@ -58,7 +58,7 @@ public class SuppressionsLoaderTest @Test public void testLoadFromURL() throws CheckstyleException { - final FilterSet fc = SuppressionsLoader.loadSuppressions("http://checkstyle.hg.sourceforge.net/hgweb/checkstyle/checkstyle/raw-file/055e288619a5/src/testinputs/com/puppycrawl/tools/checkstyle/suppressions_none.xml"); + final FilterSet fc = SuppressionsLoader.loadSuppressions("http://sourceforge.net/p/checkstyle/code/ci/default/tree/src/testinputs/com/puppycrawl/tools/checkstyle/suppressions_none.xml?format=raw"); final FilterSet fc2 = new FilterSet(); assertEquals(fc, fc2); }