Skip to content

Commit

Permalink
Issue #729: upgrade to checkstyle and eclipse-cs 8.18
Browse files Browse the repository at this point in the history
  • Loading branch information
romani committed Mar 25, 2019
1 parent 0a5c948 commit bb55d3c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 35 deletions.
2 changes: 1 addition & 1 deletion sevntu-checks/pom.xml
Expand Up @@ -16,7 +16,7 @@
<properties>
<project.build.sourceEncoding>iso-8859-1</project.build.sourceEncoding>
<!-- It is compile dependency to checkstyle, this version has to be the same as eclipse-cs depends on -->
<checkstyle.eclipse-cs.version>8.12</checkstyle.eclipse-cs.version>
<checkstyle.eclipse-cs.version>8.18</checkstyle.eclipse-cs.version>
<checkstyle.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.eclipse-cs.version}/config/checkstyle_checks.xml</checkstyle.configLocation>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
<sevntu.maven.plugin>RELEASE</sevntu.maven.plugin>
Expand Down
Expand Up @@ -68,8 +68,9 @@ public void testWithEmptyArgumentCount() throws Exception {
catch (CheckstyleException ex) {
checkExceptionMessage(ex,
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to '' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to ''");
}
}

Expand All @@ -86,8 +87,9 @@ public void testWithSpacesForArgumentCount() throws Exception {
catch (CheckstyleException ex) {
checkExceptionMessage(ex,
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to ' ' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to ' '");
}
}

Expand All @@ -104,8 +106,9 @@ public void testWithSpacesAndCommaForArgumentCount() throws Exception {
catch (CheckstyleException ex) {
checkExceptionMessage(ex,
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to ' , ' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to ' , '");
}
}

Expand All @@ -122,8 +125,9 @@ public void testWithNullArgumentCount() throws Exception {
catch (CheckstyleException ex) {
checkExceptionMessage(ex,
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to 'null' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to 'null'");
}
}

Expand Down Expand Up @@ -167,8 +171,9 @@ public void testNullMethodNameRegex() throws Exception {
catch (CheckstyleException ex) {
checkExceptionMessage(ex,
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'methodName' to 'null' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'methodName' to 'null'");
}
}

Expand All @@ -192,57 +197,64 @@ public void testBadMethodNameRegex() throws Exception {
catch (CheckstyleException ex) {
checkExceptionMessage(ex,
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'methodName' to '[exit' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'methodName' to '[exit'");
}
}

@Test
public void testBadRangeForArgumentCount() throws Exception {
testBadRangeInner("badArgCount",
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to 'badArgCount' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to 'badArgCount'");
}

@Test
public void testBadRange2ForArgumentCount() throws Exception {
testBadRangeInner("badStart-badEnd",
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to 'badStart-badEnd' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to 'badStart-badEnd'");
}

@Test
public void testBadRange3ForArgumentCount() throws Exception {
testBadRangeInner("2, badStart-badEnd",
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to '2, badStart-badEnd' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to '2, badStart-badEnd'");
}

@Test
public void testBadRange4ForArgumentCount() throws Exception {
testBadRangeInner(" , 1-4 ",
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to ' , 1-4 ' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to ' , 1-4 '");
}

@Test
public void testUnboundedRangeForArgumentCount() throws Exception {
testBadRangeInner(" - ",
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to ' - ' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to ' - '");
}

@Test
public void testRangeWithBadBoundsForArgumentCount() throws Exception {
testBadRangeInner("10-1",
"cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'argumentCount' to '10-1' in module "
+ "com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck");
+ "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.ForbidCertainMethodCheck -"
+ " Cannot set property 'argumentCount' to '10-1'");
}

private void testBadRangeInner(String value, String expectedMessage) throws Exception {
Expand Down
Expand Up @@ -84,9 +84,9 @@ public void testWithNegativeTernaryPerExpressionCountValue()
}
catch (CheckstyleException ex) {
final String errorMsg = ex.getMessage();
final String expectedMessage = "Cannot set property 'maxTernaryPerExpressionCount' "
+ "to '-1' in module com.github.sevntu.checkstyle.checks.coding."
+ "TernaryPerExpressionCountCheck";
final String expectedMessage = "cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.coding.TernaryPerExpressionCountCheck -"
+ " Cannot set property 'maxTernaryPerExpressionCount' to '-1'";
Assert.assertTrue("Expected error message is missing: " + expectedMessage,
errorMsg.contains(expectedMessage));
}
Expand Down
Expand Up @@ -125,9 +125,11 @@ public void testInvalidFormat()
fail();
}
catch (CheckstyleException ex) {
final String messagePrefix = "cannot initialize module "
+ "com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'formats' to '\\' in module ";
final String messagePrefix = "cannot initialize module"
+ " com.puppycrawl.tools.checkstyle.TreeWalker -"
+ " cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.naming.UniformEnumConstantNameCheck -"
+ " Cannot set property 'formats' to '\\'";
Assert.assertTrue("Exception's message does not start with: " + messagePrefix,
ex.getMessage().startsWith(messagePrefix));
}
Expand Down
Expand Up @@ -96,9 +96,10 @@ public void testProperty() throws Exception {
fail();
}
catch (CheckstyleException ex) {
final String messagePrefix = "cannot initialize module "
+ "com.puppycrawl.tools.checkstyle.TreeWalker - "
+ "Cannot set property 'ignorePattern' to '[' in module ";
final String messagePrefix = "cannot initialize module"
+ " com.puppycrawl.tools.checkstyle.TreeWalker - cannot initialize module"
+ " com.github.sevntu.checkstyle.checks.sizes.LineLengthExtendedCheck -"
+ " Cannot set property 'ignorePattern' to '['";
Assert.assertTrue("Exception's message does not start with: " + messagePrefix,
ex.getMessage().startsWith(messagePrefix));
}
Expand Down
2 changes: 1 addition & 1 deletion sevntu-checkstyle-sonar-plugin/pom.xml
Expand Up @@ -26,7 +26,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<checkstyle.version>8.7</checkstyle.version>
<checkstyle.version>8.18</checkstyle.version>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
</properties>

Expand Down

0 comments on commit bb55d3c

Please sign in to comment.