Make the tests pass

Fix Checkstyle errors
This commit is contained in:
Oliver Burn 2013-08-30 16:32:31 +10:00
parent 3852e12bec
commit d86329ca8f
2 changed files with 14 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -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);
}