From 4da2bb19f8c602763516b73899abb78f39d63afa Mon Sep 17 00:00:00 2001 From: fw8899 Date: Tue, 12 Jun 2018 15:00:44 +0800 Subject: [PATCH] fix: #312 --- .../rule/oop/PojoMustOverrideToStringRule.java | 4 ++++ .../rule/oop/xml/PojoMustOverrideToStringRule.xml | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/PojoMustOverrideToStringRule.java b/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/PojoMustOverrideToStringRule.java index a8ed12c..b5193ed 100644 --- a/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/PojoMustOverrideToStringRule.java +++ b/p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/PojoMustOverrideToStringRule.java @@ -59,6 +59,10 @@ public class PojoMustOverrideToStringRule extends AbstractPojoRule { @Override public Object visit(ASTClassOrInterfaceDeclaration node, Object data) { + if (node.isInterface()) { + return super.visit(node, data); + } + if (!isPojo(node)) { return super.visit(node, data); } diff --git a/p3c-pmd/src/test/resources/com/alibaba/p3c/pmd/lang/java/rule/oop/xml/PojoMustOverrideToStringRule.xml b/p3c-pmd/src/test/resources/com/alibaba/p3c/pmd/lang/java/rule/oop/xml/PojoMustOverrideToStringRule.xml index 23796e2..7bc0827 100644 --- a/p3c-pmd/src/test/resources/com/alibaba/p3c/pmd/lang/java/rule/oop/xml/PojoMustOverrideToStringRule.xml +++ b/p3c-pmd/src/test/resources/com/alibaba/p3c/pmd/lang/java/rule/oop/xml/PojoMustOverrideToStringRule.xml @@ -132,4 +132,19 @@ 0 + + + + + + + + interface with POJO surfix + 0 + + + \ No newline at end of file -- GitLab