Fix SeparatorWrap Check violations in Checkstyle code. #945

This commit is contained in:
Michal Kordas 2015-05-12 22:08:09 +02:00 committed by Roman Ivanov
parent 7fdcaa5929
commit 466b1ebb31
18 changed files with 79 additions and 76 deletions

View File

@ -254,6 +254,14 @@
<module name="NoClone"/>
<module name="NoFinalizer"/>
<module name="NoLineWrap"/>
<module name="SeparatorWrap">
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="StringLiteralEquality"/>
<module name="SuperClone"/>
<module name="SuperFinalize"/>
@ -295,7 +303,6 @@
<module name="TrailingComment"/>
<module name="RequireThis"/>
<module name="ReturnCount"/>
<module name="SeparatorWrap"/>
<module name="SingleLineJavadoc"/>
<module name="SummaryJavadoc"/>
<module name="ThrowsCount"/>

View File

@ -62,8 +62,8 @@ public final class Main
* @throws CheckstyleException if there is a problem with parsing a property file
* @throws FileNotFoundException if there is a problem with files access
**/
public static void main(String... args) throws UnsupportedEncodingException
, CheckstyleException, FileNotFoundException
public static void main(String... args) throws UnsupportedEncodingException,
CheckstyleException, FileNotFoundException
{
int errorCounter = 0;
boolean cliViolations = false;

View File

@ -327,8 +327,8 @@ public final class TreeWalker
* @param contents the contents of the file the AST was generated from.
* @param astState state of AST.
*/
private void walk(DetailAST ast, FileContents contents
, AstState astState)
private void walk(DetailAST ast, FileContents contents,
AstState astState)
{
notifyBegin(ast, contents, astState);
@ -345,8 +345,8 @@ public final class TreeWalker
* @param contents the contents of the file the AST was generated from.
* @param astState state of AST.
*/
private void notifyBegin(DetailAST rootAST, FileContents contents
, AstState astState)
private void notifyBegin(DetailAST rootAST, FileContents contents,
AstState astState)
{
Set<Check> checks;

View File

@ -200,8 +200,8 @@ public class FinalParametersCheck extends Check
{
boolean result = false;
if (ignorePrimitiveTypes) {
final DetailAST parameterType = paramDef.
findFirstToken(TokenTypes.TYPE).getFirstChild();
final DetailAST parameterType = paramDef
.findFirstToken(TokenTypes.TYPE).getFirstChild();
if (primitiveDataTypes.contains(parameterType.getType())) {
result = true;
}

View File

@ -356,8 +356,8 @@ public final class AnnotationUseStyleCheck extends Check
valuePair.findFirstToken(TokenTypes.ANNOTATION_ARRAY_INIT);
if (nestedArrayInit != null
&& AnnotationUseStyleCheck.
ANNOTATION_ELEMENT_SINGLE_NAME.equals(
&& AnnotationUseStyleCheck
.ANNOTATION_ELEMENT_SINGLE_NAME.equals(
valuePair.getFirstChild().getText())
&& nestedArrayInit.getChildCount(TokenTypes.EXPR) == 1)
{

View File

@ -184,8 +184,8 @@ public final class MissingDeprecatedCheck extends Check
final Matcher javadocNoargMatcher =
MissingDeprecatedCheck.MATCH_DEPRECATED.matcher(line);
final Matcher noargMultilineStart =
MissingDeprecatedCheck.
MATCH_DEPRECATED_MULTILINE_START.matcher(line);
MissingDeprecatedCheck
.MATCH_DEPRECATED_MULTILINE_START.matcher(line);
if (javadocNoargMatcher.find()) {
if (found) {

View File

@ -256,8 +256,8 @@ public class EmptyCatchBlockCheck extends Check
private boolean isVerifiable(DetailAST emptyCatchAst, String commentContent)
{
final String exceptionVariableName = getExceptionVariableName(emptyCatchAst);
final boolean isMatchingVariableName = variableNameRegexp.
matcher(exceptionVariableName).find();
final boolean isMatchingVariableName = variableNameRegexp
.matcher(exceptionVariableName).find();
final boolean isMatchingCommentContent = !commentContent.isEmpty()
&& commentRegexp.matcher(commentContent).find();
return !isMatchingVariableName && !isMatchingCommentContent;

View File

@ -203,8 +203,8 @@ public final class IllegalTypeCheck extends AbstractFormatCheck
boolean result = true;
if (memberModifiers != null) {
result = false;
final DetailAST modifiersAst = methodOrVariableDef.
findFirstToken(TokenTypes.MODIFIERS);
final DetailAST modifiersAst = methodOrVariableDef
.findFirstToken(TokenTypes.MODIFIERS);
if (modifiersAst.getFirstChild() != null) {
for (DetailAST modifier = modifiersAst.getFirstChild(); modifier != null;
modifier = modifier.getNextSibling())
@ -329,8 +329,8 @@ public final class IllegalTypeCheck extends AbstractFormatCheck
private void extendIllegalClassNamesWithShortName(String canonicalName)
{
if (illegalClassNames.contains(canonicalName)) {
final String shortName = canonicalName.
substring(canonicalName.lastIndexOf('.') + 1);
final String shortName = canonicalName
.substring(canonicalName.lastIndexOf('.') + 1);
illegalClassNames.add(shortName);
}
}

View File

@ -370,8 +370,8 @@ public class VariableDeclarationUsageDistanceCheck extends Check
break;
case TokenTypes.VARIABLE_DEF:
final String currentVariableName = currentSiblingAst.
findFirstToken(TokenTypes.IDENT).getText();
final String currentVariableName = currentSiblingAst
.findFirstToken(TokenTypes.IDENT).getText();
isUsedVariableDeclarationFound = variableName.equals(currentVariableName);
break;

View File

@ -130,8 +130,8 @@ public class OneTopLevelClassCheck extends Check
publicTypeFound = true;
}
else {
final String typeName = currentNode.
findFirstToken(TokenTypes.IDENT).getText();
final String typeName = currentNode
.findFirstToken(TokenTypes.IDENT).getText();
lineNumberTypeMap.put(currentNode.getLineNo(), typeName);
}
}

View File

@ -649,8 +649,8 @@ public class CustomImportOrderCheck extends Check
*/
private static String getFullImportIdent(DetailAST token)
{
return token != null ? FullIdent.createFullIdent(token.
findFirstToken(TokenTypes.DOT)).getText() : "";
return token != null ? FullIdent.createFullIdent(token
.findFirstToken(TokenTypes.DOT)).getText() : "";
}
/**

View File

@ -77,8 +77,7 @@ public class SwitchHandler extends BlockParentHandler
private void checkSwitchExpr()
{
checkExpressionSubtree(
getMainAst().findFirstToken(TokenTypes.LPAREN).
getNextSibling(),
getMainAst().findFirstToken(TokenTypes.LPAREN).getNextSibling(),
getLevel(),
false,
false);

View File

@ -288,8 +288,8 @@ public abstract class AbstractJavadocCheck extends Check
JavadocNodeImpl[] children = new JavadocNodeImpl[childCount];
for (int i = 0; i < childCount; i++) {
final JavadocNodeImpl child = createJavadocNode(parseTreeNode.getChild(i)
, rootJavadocNode, i);
final JavadocNodeImpl child = createJavadocNode(parseTreeNode.getChild(i),
rootJavadocNode, i);
children[i] = child;
}
rootJavadocNode.setChildren(children);
@ -310,8 +310,8 @@ public abstract class AbstractJavadocCheck extends Check
for (int j = 0; j < subChildren.length; j++) {
final JavadocNodeImpl child =
createJavadocNode(currentParseTreeNodeChild.getChild(j)
, currentJavadocNode, j);
createJavadocNode(currentParseTreeNodeChild.getChild(j),
currentJavadocNode, j);
subChildren[j] = child;
}

View File

@ -80,8 +80,8 @@ public final class JavadocUtils
}
}
catch (Exception e) {
throw new IllegalStateException("Failed to instantiate collection of Javadoc tokens"
, e);
throw new IllegalStateException(
"Failed to instantiate collection of Javadoc tokens", e);
}
}

View File

@ -131,8 +131,8 @@ public class MainTest
assertEquals("", errorLog.getLog());
}
});
Main.main("-c", "src/main/resources/non_existing_config.xml"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c", "src/main/resources/non_existing_config.xml",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -145,13 +145,13 @@ public class MainTest
public void checkAssertion()
{
assertEquals("Invalid output format."
+ " Found '" + "xmlp" + "' but expected 'plain' or 'xml'.\n"
, standardLog.getLog());
+ " Found '" + "xmlp" + "' but expected 'plain' or 'xml'.\n",
standardLog.getLog());
assertEquals("", errorLog.getLog());
}
});
Main.main("-c", "/google_checks.xml", "-f" , "xmlp"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c", "/google_checks.xml", "-f" , "xmlp",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -168,8 +168,8 @@ public class MainTest
assertEquals("", errorLog.getLog());
}
});
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -195,9 +195,9 @@ public class MainTest
assertEquals("", errorLog.getLog());
}
});
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml"
, "-f", "xml"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml",
"-f", "xml",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -214,9 +214,9 @@ public class MainTest
assertEquals("", errorLog.getLog());
}
});
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml"
, "-f", "plain"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml",
"-f", "plain",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -236,13 +236,13 @@ public class MainTest
+ currentPath
+ "/src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java:5:7: "
+ "warning: Name 'InputMainInner' must match pattern '^[a-z0-9]*$'.\n"
+ "Audit done.\n"
, standardLog.getLog());
+ "Audit done.\n",
standardLog.getLog());
assertEquals("", errorLog.getLog());
}
});
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname2.xml"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname2.xml",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -267,9 +267,9 @@ public class MainTest
assertEquals("", errorLog.getLog());
}
});
Main.main("-c"
, "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname2-error.xml"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c",
"src/test/resources/com/puppycrawl/tools/checkstyle/config-classname2-error.xml",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -285,10 +285,10 @@ public class MainTest
assertEquals("", errorLog.getLog());
}
});
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml"
, "-f", "plain"
, "-o", "myjava.java"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml",
"-f", "plain",
"-o", "myjava.java",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -308,10 +308,10 @@ public class MainTest
assertEquals("", errorLog.getLog());
}
});
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml"
, "-f", "plain"
, "-o", file.getCanonicalPath()
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml",
"-f", "plain",
"-o", file.getCanonicalPath(),
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -329,9 +329,9 @@ public class MainTest
}
});
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/"
+ "config-classname-prop.xml"
, "-p", "src/test/resources/com/puppycrawl/tools/checkstyle/mycheckstyle.properties"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
+ "config-classname-prop.xml",
"-p", "src/test/resources/com/puppycrawl/tools/checkstyle/mycheckstyle.properties",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
@Test
@ -348,8 +348,8 @@ public class MainTest
}
});
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/"
+ "config-classname-prop.xml"
, "-p", "nonexisting.properties"
, "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
+ "config-classname-prop.xml",
"-p", "nonexisting.properties",
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}
}

View File

@ -136,7 +136,7 @@ public class FinalLocalVariableCheckTest
checkConfig.addAttribute("tokens", "PARAMETER_DEF,VARIABLE_DEF");
final String[] expected = {};
verify(checkConfig, new File("src/test/resources-noncompilable/com/puppycrawl/"
+ "tools/checkstyle/naming/InputFinalLocalVariableNameLambda.java").
getCanonicalPath(), expected);
+ "tools/checkstyle/naming/InputFinalLocalVariableNameLambda.java")
.getCanonicalPath(), expected);
}
}

View File

@ -27,8 +27,7 @@ import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck.MSG_ASSIGN;
import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck.MSG_EXPR;
import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck.MSG_IDENT;
import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck.
MSG_LITERAL;
import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck.MSG_LITERAL;
import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck.MSG_RETURN;
import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck.MSG_STRING;

View File

@ -24,10 +24,8 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.
WS_NOT_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.
WS_NOT_PRECEDED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.WS_NOT_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.WS_NOT_PRECEDED;
public class WhitespaceAroundTest
extends BaseCheckTestSupport