From 8f363ceb3db90c6f1f5db8a98b53b7fb174084ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Mon, 27 Apr 2020 19:13:00 +0200 Subject: [PATCH] Fix tests --- .../net/sourceforge/pmd/properties/PropertyFactory.java | 3 +++ .../sourceforge/pmd/renderers/CodeClimateRendererTest.java | 2 +- .../pmd/lang/ecmascript/EcmascriptParserOptions.java | 2 +- .../pmd/lang/ecmascript/EcmascriptParserOptionsTest.java | 7 +++++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyFactory.java index 2a1a10c239..94654fef2b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyFactory.java @@ -294,6 +294,9 @@ public final class PropertyFactory { * * @return A new builder */ + // Note: there is a bug, whereby the default value can be set on + // the builder, even if it wasn't registered in the constants + // This is fixed in the framework refactoring public static GenericPropertyBuilder enumProperty(String name, Map nameToValue) { // TODO find solution to document the set of possible values // At best, map that requirement to a constraint (eg make parser return null if not found, and diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java index 089c8d12a2..9ede80cac5 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java @@ -52,8 +52,8 @@ public class CodeClimateRendererTest extends AbstractRendererTest { + "Name | Value | Description\\n" + "--- | --- | ---\\n" + "violationSuppressRegex | | Suppress violations with messages matching a regular expression\\n" + "violationSuppressXPath | | Suppress violations on nodes which match a given relative XPath expression.\\n" - + "multiString | default1,default2 | multi string property\\n" + "stringProperty | the string value\\nsecond line with 'quotes' | simple string property\\n" + + "multiString | default1,default2 | multi string property\\n" + "\"},\"categories\":[\"Style\"],\"location\":{\"path\":\"" + getSourceCodeFilename() + "\",\"lines\":{\"begin\":1,\"end\":1}},\"severity\":\"info\",\"remediation_points\":50000}" + "\u0000" + PMD.EOL; } diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java index 48a21f015e..cbeb75e1a6 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptions.java @@ -70,7 +70,7 @@ public class EcmascriptParserOptions extends ParserOptions { public static final PropertyDescriptor RHINO_LANGUAGE_VERSION = PropertyFactory.enumProperty("rhinoLanguageVersion", associateBy(asList(Version.values()), Version::getLabel)) .desc("Specifies the Rhino Language Version to use for parsing. Defaults to Rhino default.") - .defaultValue(Version.VERSION_DEFAULT) + .defaultValue(Version.VERSION_ES6) .build(); private boolean recordingComments; diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptionsTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptionsTest.java index e21c801c49..b343d5bbdc 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptionsTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptParserOptionsTest.java @@ -5,11 +5,14 @@ package net.sourceforge.pmd.lang.ecmascript; import static net.sourceforge.pmd.lang.ParserOptionsTest.verifyOptionsEqualsHashcode; +import static net.sourceforge.pmd.util.CollectionUtil.listOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.util.List; + import org.junit.Test; import net.sourceforge.pmd.lang.ParserOptions; @@ -68,8 +71,8 @@ public class EcmascriptParserOptionsTest { @Test public void testEqualsHashcode() throws Exception { @SuppressWarnings("unchecked") - PropertyDescriptor[] properties = new PropertyDescriptor[] {EcmascriptParserOptions.RECORDING_COMMENTS_DESCRIPTOR, - EcmascriptParserOptions.RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR,}; + List> properties = listOf(EcmascriptParserOptions.RECORDING_COMMENTS_DESCRIPTOR, + EcmascriptParserOptions.RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR); for (PropertyDescriptor property : properties) { MyRule rule = new MyRule();