Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to checkstyle 8.19 #158

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion net.sf.eclipsecs.checkstyle/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="checkstyle-8.18-all.jar" sourcepath="checkstyle-checkstyle-8.18.zip"/>
<classpathentry exported="true" kind="lib" path="checkstyle-8.19-all.jar" sourcepath="checkstyle-checkstyle-8.19.zip"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
18 changes: 9 additions & 9 deletions net.sf.eclipsecs.checkstyle/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Checkstyle Library
Bundle-SymbolicName: net.sf.eclipsecs.checkstyle
Bundle-Version: 8.18.0.qualifier
Bundle-Version: 8.19.0.qualifier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This accidental number update causes the build to fail

Bundle-Vendor: Eclipse Checkstyle Project
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: .,
antlr;version="8.18.0";
antlr;version="8.19.0";
uses:="antlr.collections.impl,
antlr.collections,
antlr.ASdebug,
antlr.debug",
antlr.collections;version="8.18.0";uses:=antlr,
com.google.common.base;version="8.18.0",
com.google.common.cache;version="8.18.0",
com.google.common.collect;version="8.18.0",
com.google.common.io;version="8.18.0",
antlr.collections;version="8.19.0";uses:=antlr,
com.google.common.base;version="8.19.0",
com.google.common.cache;version="8.19.0",
com.google.common.collect;version="8.19.0",
com.google.common.io;version="8.19.0",
com.puppycrawl.tools.checkstyle,
com.puppycrawl.tools.checkstyle.api;
uses:="org.xml.sax.helpers,
Expand Down Expand Up @@ -44,7 +44,7 @@ Export-Package: .,
com.puppycrawl.tools.checkstyle.filefilters,
com.puppycrawl.tools.checkstyle.filters,
com.puppycrawl.tools.checkstyle.utils,
org.apache.commons.beanutils;version="8.18.0"
org.apache.commons.beanutils;version="8.19.0"
Bundle-ClassPath: .,
checkstyle-8.18-all.jar
checkstyle-8.19-all.jar
Automatic-Module-Name: net.sf.eclipsecs.checkstyle
2 changes: 1 addition & 1 deletion net.sf.eclipsecs.checkstyle/build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bin.includes = META-INF/,\
.,\
license/,\
checkstyle-8.18-all.jar
checkstyle-8.19-all.jar
jars.compile.order = .
source.. = metadata/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@
<alternative-name internal-name="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck" />
<description>%AnnotationLocation.desc</description>
<property-metadata name="tokens" datatype="MultiCheck"
default-value="CLASS_DEF,INTERFACE_DEF,ENUM_DEF,METHOD_DEF,CTOR_DEF,VARIABLE_DEF">
default-value="CLASS_DEF,INTERFACE_DEF,PACKAGE_DEF,ENUM_CONSTANT_DEF,ENUM_DEF,METHOD_DEF,CTOR_DEF,VARIABLE_DEF">
<description>%AnnotationLocation.tokens</description>
<enumeration>
<property-value-option value="CLASS_DEF" />
<property-value-option value="INTERFACE_DEF" />
<property-value-option value="PACKAGE_DEF" />
<property-value-option value="ENUM_CONSTANT_DEF" />
<property-value-option value="ENUM_DEF" />
<property-value-option value="METHOD_DEF" />
<property-value-option value="CTOR_DEF" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Checker.localeLanguage = locale language for messages
Checker.charset = name of the file charset (Note: eclipse-cs plugin sets this property to the projects default charset)
Checker.fileExtensions = file extensions that are accepted (comma separated)
Checker.haltOnException = Controls whether exceptions should halt execution or not.
Checker.tabWidth = number of expanded spaces for a tab character (<code>'\t'</code>); used in messages and Checks that print violations on files with tabs.

TreeWalker.name = TreeWalker
TreeWalker.desc = FileSetCheck TreeWalker checks individual Java source files and defines properties that are applicable to checking such files.
TreeWalker.tabWidth = number of expanded spaces for a tab character ('\t'); used in messages and Checks that require a tab width, such as LineLength
TreeWalker.fileExtensions = file type extension to identify java files. Setting this property is typically only required if your java source code is preprocessed before compilation and the original files do not have the extension .java
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
<property-metadata name="haltOnException" datatype="Boolean" default-value="true">
<description>%Checker.haltOnException</description>
</property-metadata>
<property-metadata name="tabWidth" datatype="Integer" default-value="8">
<description>%Checker.tabWidth</description>
</property-metadata>
</rule-metadata>

<rule-metadata name="%TreeWalker.name" internal-name="TreeWalker" parent="Checker"
singleton="true">
<alternative-name internal-name="com.puppycrawl.tools.checkstyle.TreeWalker"/>
<description>%TreeWalker.desc</description>
<property-metadata name="tabWidth" datatype="Integer" default-value="8">
<description>%TreeWalker.tabWidth</description>
</property-metadata>
<property-metadata name="fileExtensions" datatype="String" default-value="java">
<description>%TreeWalker.fileExtensions</description>
</property-metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ public void testMetadataFiles() throws Exception {
Assert.assertTrue("folder " + p + " must exist in eclipsecs",
new File(getEclipseCsPath(p, "")).exists());

final Set<Class<?>> packgeModules = CheckUtil.getModulesInPackage(modules, p);
final Set<Class<?>> packageModules = CheckUtil.getModulesInPackage(modules, p);

validateEclipseCsMetaXmlFile(new File(getEclipseCsPath(p, "/checkstyle-metadata.xml")), p,
new HashSet<>(packgeModules));
new HashSet<>(packageModules));

validateEclipseCsMetaPropFile(
new File(getEclipseCsPath(p, "/checkstyle-metadata.properties")), p,
new HashSet<>(packgeModules));
new HashSet<>(packageModules));
}
}

private static void validateEclipseCsMetaXmlFile(File file, String packge,
Set<Class<?>> packgeModules) throws Exception {
Assert.assertTrue("'checkstyle-metadata.xml' must exist in eclipsecs in inside " + packge,
Set<Class<?>> packageModules) throws Exception {
Assert.assertTrue("'checkstyle-metadata.xml' must exist in eclipsecs inside " + packge,
file.exists());

final String input = new String(Files.readAllBytes(file.toPath()), UTF_8);
Expand All @@ -66,16 +66,16 @@ private static void validateEclipseCsMetaXmlFile(File file, String packge,
final Node ruleGroup = ruleGroups.item(position);
final Set<Node> children = XmlUtil.getChildrenElements(ruleGroup);

validateEclipseCsMetaXmlFileRules(packge, packgeModules, children);
validateEclipseCsMetaXmlFileRules(packge, packageModules, children);
}

for (Class<?> module : packgeModules) {
for (Class<?> module : packageModules) {
Assert.fail("Module not found in " + packge + " checkstyle-metadata.xml: "
+ module.getCanonicalName());
}
}

private static void validateEclipseCsMetaXmlFileRules(String packge, Set<Class<?>> packgeModules,
private static void validateEclipseCsMetaXmlFileRules(String packge, Set<Class<?>> packageModules,
Set<Node> rules) throws Exception {
for (Node rule : rules) {
final NamedNodeMap attributes = rule.getAttributes();
Expand All @@ -87,8 +87,8 @@ private static void validateEclipseCsMetaXmlFileRules(String packge, Set<Class<?
final String internalName = internalNameNode.getTextContent();
final String classpath = packge + "." + internalName;

final Class<?> module = findModule(packgeModules, classpath);
packgeModules.remove(module);
final Class<?> module = findModule(packageModules, classpath);
packageModules.remove(module);

Assert.assertNotNull(
"Unknown class found in " + packge + " checkstyle-metadata.xml: " + internalName,
Expand Down Expand Up @@ -330,17 +330,17 @@ private static String getQuickfixClass(Class<?> module) throws IOException {
}

private static void validateEclipseCsMetaPropFile(File file, String packge,
Set<Class<?>> packgeModules) throws Exception {
Set<Class<?>> packageModules) throws Exception {
Assert.assertTrue(
"'checkstyle-metadata.properties' must exist in eclipsecs in inside " + packge,
"'checkstyle-metadata.properties' must exist in eclipsecs inside " + packge,
file.exists());

final Properties prop = new Properties();
prop.load(new FileInputStream(file));

final Set<Object> properties = new HashSet<>(Collections.list(prop.keys()));

for (Class<?> module : packgeModules) {
for (Class<?> module : packageModules) {
final String moduleName = CheckUtil.getSimpleCheckstyleModuleName(module);

Assert.assertTrue(moduleName + " requires a name in eclipsecs properties " + packge,
Expand Down
18 changes: 10 additions & 8 deletions net.sf.eclipsecs.core/.classpath
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry exported="true" kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public final class ConfigurationReader {
map.put(DTD_PUBLIC_CS_ID_1_1, DTD_CONFIGURATION_NAME_1_1);
map.put(DTD_PUBLIC_CS_ID_1_2, DTD_CONFIGURATION_NAME_1_2);
map.put(DTD_PUBLIC_CS_ID_1_3, DTD_CONFIGURATION_NAME_1_3);

PUBLIC2INTERNAL_DTD_MAP = map;
}

Expand Down Expand Up @@ -172,17 +172,17 @@ public static AdditionalConfigData getAdditionalConfigData(InputSource in)
for (final Module module : modules) {

if ((module.getMetaData() != null)
&& module.getMetaData().getInternalName().equals(XMLTags.TREEWALKER_MODULE)) {
&& (XMLTags.TREEWALKER_MODULE.equals(module.getMetaData().getInternalName())
|| XMLTags.CHECKER_MODULE.equals(module.getMetaData().getInternalName()))) {

final ConfigProperty prop = module.getProperty("tabWidth"); //$NON-NLS-1$

String tabWidthProp = null;

if (prop != null) {
tabWidthProp = prop.getValue();
if (prop == null) {
continue;
}

if (tabWidthProp == null && prop != null && prop.getMetaData() != null) {
String tabWidthProp = prop.getValue();

if (tabWidthProp == null && prop.getMetaData() != null) {
tabWidthProp = prop.getMetaData().getDefaultValue();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.sf.eclipsecs.core.config;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

import org.junit.Test;
import org.xml.sax.InputSource;

import net.sf.eclipsecs.core.config.ConfigurationReader.AdditionalConfigData;
import net.sf.eclipsecs.core.util.CheckstylePluginException;

public class ConfigurationReaderTest {

@Test
public void testNoTabwidth() throws Exception {
// 8 is hardcoded in the configuration reader as default
verifyTabWidth("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<!DOCTYPE module PUBLIC \"-//Checkstyle//DTD Check Configuration 1.3//EN\" \"https://checkstyle.org/dtds/configuration_1_3.dtd\">"
+ "<module name=\"Checker\">"
+ "</module>", 8);
}


@Test
public void testTabwidthReadFromTreeWalkerOnlyBefore8_19() throws Exception {
verifyTabWidth("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<!DOCTYPE module PUBLIC \"-//Checkstyle//DTD Check Configuration 1.3//EN\" \"https://checkstyle.org/dtds/configuration_1_3.dtd\">"
+ "<module name=\"Checker\">"
+ " <module name=\"TreeWalker\" tabWidth=\"2\">"
+ " </module>"
+ "</module>", 2);
}

@Test
public void testTabwidthAvailableEverywhere() throws Exception {
verifyTabWidth("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<!DOCTYPE module PUBLIC \"-//Checkstyle//DTD Check Configuration 1.3//EN\" \"https://checkstyle.org/dtds/configuration_1_3.dtd\">"
+ "<module name=\"Checker\" tabWidth=\"3\">"
+ " <module name=\"TreeWalker\">"
+ " </module>"
+ "</module>", 3);
}

private void verifyTabWidth(String configContent, int expectedTabwidth)
throws CheckstylePluginException, IOException {
AdditionalConfigData configData = null;
try (ByteArrayInputStream stream = new ByteArrayInputStream(
configContent.getBytes(StandardCharsets.UTF_8))) {
configData = ConfigurationReader.getAdditionalConfigData(new InputSource(stream));
}
assertNotNull(configData);
assertEquals(expectedTabwidth, configData.getTabWidth());
}

}