Merge branch 'pr-1743'
This commit is contained in:
@ -98,6 +98,8 @@ The designer will still be shipped with PMD's binaries.
|
|||||||
* java-codestyle
|
* java-codestyle
|
||||||
* [#1527](https://github.com/pmd/pmd/issues/1527): \[java] UseUnderscoresInNumericLiterals false positive on floating point numbers
|
* [#1527](https://github.com/pmd/pmd/issues/1527): \[java] UseUnderscoresInNumericLiterals false positive on floating point numbers
|
||||||
* [#1674](https://github.com/pmd/pmd/issues/1674): \[java] documentation of CommentDefaultAccessModifier is wrong
|
* [#1674](https://github.com/pmd/pmd/issues/1674): \[java] documentation of CommentDefaultAccessModifier is wrong
|
||||||
|
* java-errorprone
|
||||||
|
* [#1570](https://github.com/pmd/pmd/issues/1570): \[java] AvoidDuplicateLiterals warning about deprecated separator property when not used
|
||||||
* plsql
|
* plsql
|
||||||
* [#1510](https://github.com/pmd/pmd/issues/1510): \[plsql] Support XMLTABLE functions
|
* [#1510](https://github.com/pmd/pmd/issues/1510): \[plsql] Support XMLTABLE functions
|
||||||
* [#1716](https://github.com/pmd/pmd/issues/1716): \[plsql] Support access to whole plsql code
|
* [#1716](https://github.com/pmd/pmd/issues/1716): \[plsql] Support access to whole plsql code
|
||||||
|
@ -469,9 +469,10 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul
|
|||||||
rule.definePropertyDescriptor(prop); // Property descriptors are immutable, and can be freely shared
|
rule.definePropertyDescriptor(prop); // Property descriptors are immutable, and can be freely shared
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPropertyOverridden(prop)) {
|
||||||
rule.setProperty((PropertyDescriptor<Object>) prop, getProperty((PropertyDescriptor<Object>) prop));
|
rule.setProperty((PropertyDescriptor<Object>) prop, getProperty((PropertyDescriptor<Object>) prop));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,17 @@ public class AbstractRuleTest {
|
|||||||
|
|
||||||
public static class MyRule extends AbstractRule {
|
public static class MyRule extends AbstractRule {
|
||||||
private static final StringProperty FOO_PROPERTY = new StringProperty("foo", "foo property", "x", 1.0f);
|
private static final StringProperty FOO_PROPERTY = new StringProperty("foo", "foo property", "x", 1.0f);
|
||||||
|
private static final PropertyDescriptor<String> FOO_DEFAULT_PROPERTY = PropertyFactory.stringProperty("fooDefault")
|
||||||
|
.defaultValue("bar")
|
||||||
|
.desc("Property without value uses default value")
|
||||||
|
.build();
|
||||||
|
|
||||||
private static final StringProperty XPATH_PROPERTY = new StringProperty("xpath", "xpath property", "", 2.0f);
|
private static final StringProperty XPATH_PROPERTY = new StringProperty("xpath", "xpath property", "", 2.0f);
|
||||||
|
|
||||||
public MyRule() {
|
public MyRule() {
|
||||||
definePropertyDescriptor(FOO_PROPERTY);
|
definePropertyDescriptor(FOO_PROPERTY);
|
||||||
definePropertyDescriptor(XPATH_PROPERTY);
|
definePropertyDescriptor(XPATH_PROPERTY);
|
||||||
|
definePropertyDescriptor(FOO_DEFAULT_PROPERTY);
|
||||||
setName("MyRule");
|
setName("MyRule");
|
||||||
setMessage("my rule msg");
|
setMessage("my rule msg");
|
||||||
setPriority(RulePriority.MEDIUM);
|
setPriority(RulePriority.MEDIUM);
|
||||||
@ -223,9 +228,8 @@ public class AbstractRuleTest {
|
|||||||
assertEquals(r1.getRuleClass(), r2.getRuleClass());
|
assertEquals(r1.getRuleClass(), r2.getRuleClass());
|
||||||
assertEquals(r1.getRuleSetName(), r2.getRuleSetName());
|
assertEquals(r1.getRuleSetName(), r2.getRuleSetName());
|
||||||
assertEquals(r1.getSince(), r2.getSince());
|
assertEquals(r1.getSince(), r2.getSince());
|
||||||
}
|
|
||||||
|
|
||||||
public static junit.framework.Test suite() {
|
assertEquals(r1.isPropertyOverridden(MyRule.FOO_DEFAULT_PROPERTY),
|
||||||
return new junit.framework.JUnit4TestAdapter(AbstractRuleTest.class);
|
r2.isPropertyOverridden(MyRule.FOO_DEFAULT_PROPERTY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,10 @@ import static org.junit.Assert.assertTrue;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import net.sourceforge.pmd.Rule;
|
||||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||||
|
|
||||||
public class AvoidDuplicateLiteralsTest extends PmdRuleTst {
|
public class AvoidDuplicateLiteralsTest extends PmdRuleTst {
|
||||||
@ -50,4 +52,13 @@ public class AvoidDuplicateLiteralsTest extends PmdRuleTst {
|
|||||||
assertTrue(res.contains("b"));
|
assertTrue(res.contains("b"));
|
||||||
assertTrue(res.contains("\\"));
|
assertTrue(res.contains("\\"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSeparatorPropertyWarning() throws Exception {
|
||||||
|
AvoidDuplicateLiteralsRule rule = new AvoidDuplicateLiteralsRule();
|
||||||
|
Assert.assertFalse(rule.isPropertyOverridden(AvoidDuplicateLiteralsRule.SEPARATOR_DESCRIPTOR));
|
||||||
|
|
||||||
|
Rule copy = rule.deepCopy();
|
||||||
|
Assert.assertFalse(copy.isPropertyOverridden(AvoidDuplicateLiteralsRule.SEPARATOR_DESCRIPTOR));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user