Fix bugs with multiple fields, part of issue #706

This commit is contained in:
liscju 2015-03-06 13:03:31 +01:00 committed by Roman Ivanov
parent 93a33df5bd
commit 244eb9d0a9
3 changed files with 21 additions and 1 deletions

View File

@ -236,7 +236,7 @@ public class EmptyLineSeparatorCheck extends Check
log(nextToken.getLineNo(), MSG_SHOULD_BE_SEPARATED,
nextToken.getText());
}
else if ((!allowNoEmptyLineBetweenFields || !allowMultipleEmptyLines)
else if (!allowNoEmptyLineBetweenFields
&& nextToken.getType() != TokenTypes.RCURLY)
{
log(nextToken.getLineNo(), MSG_SHOULD_BE_SEPARATED,

View File

@ -97,4 +97,17 @@ public class EmptyLineSeparatorCheckTest
};
verify(checkConfig, getPath("whitespace/InputEmptyLineSeparatorFormerException.java"), expected);
}
@Test
public void testAllowMultipleFieldInClass() throws Exception
{
DefaultConfiguration checkConfig = createCheckConfig(EmptyLineSeparatorCheck.class);
checkConfig.addAttribute("allowMultipleEmptyLines", "false");
checkConfig.addAttribute("allowNoEmptyLineBetweenFields", "true");
final String[] expected = {
};
verify(checkConfig, getPath("whitespace/InputEmptyLineSeparatorMultipleFieldsInClass.java"), expected);
}
}

View File

@ -0,0 +1,7 @@
package com.puppycrawl.tools.checkstyle.whitespace;
public class InputEmptyLineSeparatorMultipleFieldsInClass
{
int first;
int second;
}