forked from phoedos/pmd
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
|
||||
* [#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
|
||||
* java-errorprone
|
||||
* [#1570](https://github.com/pmd/pmd/issues/1570): \[java] AvoidDuplicateLiterals warning about deprecated separator property when not used
|
||||
* plsql
|
||||
* [#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
|
||||
|
@ -468,10 +468,11 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul
|
||||
if (rule.getPropertyDescriptor(prop.name()) == null) {
|
||||
rule.definePropertyDescriptor(prop); // Property descriptors are immutable, and can be freely shared
|
||||
}
|
||||
|
||||
rule.setProperty((PropertyDescriptor<Object>) prop, getProperty((PropertyDescriptor<Object>) prop));
|
||||
|
||||
if (isPropertyOverridden(prop)) {
|
||||
rule.setProperty((PropertyDescriptor<Object>) prop, getProperty((PropertyDescriptor<Object>) prop));
|
||||
}
|
||||
}
|
||||
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
|
@ -30,12 +30,17 @@ public class AbstractRuleTest {
|
||||
|
||||
public static class MyRule extends AbstractRule {
|
||||
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);
|
||||
|
||||
public MyRule() {
|
||||
definePropertyDescriptor(FOO_PROPERTY);
|
||||
definePropertyDescriptor(XPATH_PROPERTY);
|
||||
definePropertyDescriptor(FOO_DEFAULT_PROPERTY);
|
||||
setName("MyRule");
|
||||
setMessage("my rule msg");
|
||||
setPriority(RulePriority.MEDIUM);
|
||||
@ -223,9 +228,8 @@ public class AbstractRuleTest {
|
||||
assertEquals(r1.getRuleClass(), r2.getRuleClass());
|
||||
assertEquals(r1.getRuleSetName(), r2.getRuleSetName());
|
||||
assertEquals(r1.getSince(), r2.getSince());
|
||||
}
|
||||
|
||||
public static junit.framework.Test suite() {
|
||||
return new junit.framework.JUnit4TestAdapter(AbstractRuleTest.class);
|
||||
assertEquals(r1.isPropertyOverridden(MyRule.FOO_DEFAULT_PROPERTY),
|
||||
r2.isPropertyOverridden(MyRule.FOO_DEFAULT_PROPERTY));
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,10 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class AvoidDuplicateLiteralsTest extends PmdRuleTst {
|
||||
@ -50,4 +52,13 @@ public class AvoidDuplicateLiteralsTest extends PmdRuleTst {
|
||||
assertTrue(res.contains("b"));
|
||||
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