Skip to content

Commit

Permalink
Issue checkstyle#88: upgrade checkstyle version
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach committed Nov 14, 2017
1 parent f92362c commit 034cfd7
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<checkstyle.version>8.1</checkstyle.version>
<checkstyle.version>8.4</checkstyle.version>
<maven.plugin.checkstyle.version>2.17</maven.plugin.checkstyle.version>
<maven.pmd.plugin.version>3.7</maven.pmd.plugin.version>
<maven.findbugs.plugin.version>3.0.4</maven.findbugs.plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import org.junit.Test;

import com.puppycrawl.tools.checkstyle.internal.CheckUtil;
import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil;
import com.puppycrawl.tools.checkstyle.utils.ModuleReflectionUtils;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
package com.github.checkstyle.regression.configuration;

import static com.github.checkstyle.regression.configuration.ConfigGenerator.DOCTYPE_PUBLIC;
import static com.github.checkstyle.regression.internal.FileUtils.readFile;
import static com.github.checkstyle.regression.internal.TestUtils.assertUtilsClassHasPrivateConstructor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
Expand Down Expand Up @@ -84,7 +86,7 @@ public void testGenerateConfigTextWithEmptyModuleInfos() throws Exception {
final File excepted = getExpectedXml("expected_empty_module_infos.xml");

final File actual = generateConfig(Collections.emptyList());
assertTrue("Config is not as expected", FileUtils.contentEquals(excepted, actual));
assertEquals("Config is not as expected", readFile(excepted), readFile(actual));
}

@Test
Expand All @@ -102,7 +104,7 @@ public void testGenerateConfigTextWithCheckerParentModule() throws Exception {

final File actual = generateConfig(Collections.singletonList(moduleInfo));

assertTrue("Config is not as expected", FileUtils.contentEquals(excepted, actual));
assertEquals("Config is not as expected", readFile(excepted), readFile(actual));
}

@Test
Expand All @@ -119,7 +121,7 @@ public void testGenerateConfigTextWithTreeWalkerParentModule() throws Exception
.build();

final File actual = generateConfig(Collections.singletonList(moduleInfo));
assertTrue("Config is not as expected", FileUtils.contentEquals(excepted, actual));
assertEquals("Config is not as expected", readFile(excepted), readFile(actual));
}

@Test
Expand All @@ -145,7 +147,7 @@ public void testGenerateConfigTextWithMiscModuleInfos() throws Exception {
.build();

final File actual = generateConfig(Arrays.asList(moduleInfo1, moduleInfo2));
assertTrue("Config is not as expected", FileUtils.contentEquals(excepted, actual));
assertEquals("Config is not as expected", readFile(excepted), readFile(actual));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////

package com.github.checkstyle.regression.internal;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

public final class FileUtils {
protected static final String LF_REGEX = "\n";

protected static final String CRLF_REGEX = "\\r\\n";

private FileUtils() {
}

/**
* Reads the contents of a file.
*
* @param file the file whose contents are to be read
* @return contents of the file with all {@code \r\n} replaced by {@code \n}
* @throws IOException if I/O exception occurs while reading
*/
public static String readFile(File file) throws IOException {
return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8).replaceAll(
CRLF_REGEX, LF_REGEX);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!DOCTYPE module
PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
Expand All @@ -8,10 +9,10 @@
<property name="haltOnException" value="false"/>
<!-- BeforeExecutionFileFilters is required for sources of java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>

<!-- Contents below are generated by regression-tool. -->
<module name="TreeWalker"/>
<module name="FileLengthCheck"/>
<module name="FileLengthCheck"/>
</module>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!DOCTYPE module
PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
Expand All @@ -8,7 +9,7 @@
<property name="haltOnException" value="false"/>
<!-- BeforeExecutionFileFilters is required for sources of java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>

<!-- Contents below are generated by regression-tool. -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!DOCTYPE module
PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
Expand All @@ -8,12 +9,12 @@
<property name="haltOnException" value="false"/>
<!-- BeforeExecutionFileFilters is required for sources of java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>

<!-- Contents below are generated by regression-tool. -->
<module name="TreeWalker">
<module name="EmptyStatementCheck"/>
</module>
<module name="NewlineAtEndOfFileCheck"/>
<module name="EmptyStatementCheck"/>
</module>
<module name="NewlineAtEndOfFileCheck"/>
</module>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!DOCTYPE module
PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
Expand All @@ -8,11 +9,11 @@
<property name="haltOnException" value="false"/>
<!-- BeforeExecutionFileFilters is required for sources of java9 -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>

<!-- Contents below are generated by regression-tool. -->
<module name="TreeWalker">
<module name="HiddenFieldCheck"/>
</module>
<module name="HiddenFieldCheck"/>
</module>
</module>

0 comments on commit 034cfd7

Please sign in to comment.