Merge pull request #220 from SeanCai/master

fix some issues
pull/292/head
玄坛 7 years ago committed by GitHub
commit 6cc59402fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -74,7 +74,6 @@ class AliLocalInspectionToolProvider : InspectionToolProvider {
AliAccessStaticViaInstanceInspection::class.java, AliAccessStaticViaInstanceInspection::class.java,
AliDeprecationInspection::class.java, AliDeprecationInspection::class.java,
MapOrSetKeyShouldOverrideHashCodeEqualsInspection::class.java, MapOrSetKeyShouldOverrideHashCodeEqualsInspection::class.java,
AliAccessToNonThreadSafeStaticFieldFromInstanceInspection::class.java,
AliArrayNamingShouldHaveBracketInspection::class.java, AliArrayNamingShouldHaveBracketInspection::class.java,
AliControlFlowStatementWithoutBracesInspection::class.java, AliControlFlowStatementWithoutBracesInspection::class.java,
AliEqualsAvoidNullInspection::class.java, AliEqualsAvoidNullInspection::class.java,

@ -37,7 +37,7 @@ import javax.swing.JComponent
* @date 2016/12/08 * @date 2016/12/08
*/ */
class AliDeprecationInspection : DeprecationInspection, AliBaseInspection { class AliDeprecationInspection : DeprecationInspection, AliBaseInspection {
val messageKey = "com.alibaba.p3c.idea.inspection.standalone.AliDeprecationInspection" private val messageKey = "com.alibaba.p3c.idea.inspection.standalone.AliDeprecationInspection"
constructor() constructor()
/** /**
@ -46,7 +46,7 @@ class AliDeprecationInspection : DeprecationInspection, AliBaseInspection {
constructor(any: Any?) : this() constructor(any: Any?) : this()
init { init {
IGNORE_INSIDE_DEPRECATED = false IGNORE_INSIDE_DEPRECATED = true
IGNORE_ABSTRACT_DEPRECATED_OVERRIDES = false IGNORE_ABSTRACT_DEPRECATED_OVERRIDES = false
IGNORE_IMPORT_STATEMENTS = false IGNORE_IMPORT_STATEMENTS = false
IGNORE_METHODS_OF_DEPRECATED = false IGNORE_METHODS_OF_DEPRECATED = false

@ -80,14 +80,12 @@ class SourceCodeProcessor(private val configuration: PMDConfiguration) {
} }
private fun usesDFA(languageVersion: LanguageVersion, rootNode: Node, ruleSets: RuleSets) { private fun usesDFA(languageVersion: LanguageVersion, rootNode: Node, ruleSets: RuleSets) {
if (ruleSets.usesDFA(languageVersion.language)) {
val start = System.nanoTime() val start = System.nanoTime()
val dataFlowFacade = languageVersion.languageVersionHandler.dataFlowFacade val dataFlowFacade = languageVersion.languageVersionHandler.dataFlowFacade
dataFlowFacade.start(rootNode) dataFlowFacade.start(rootNode)
val end = System.nanoTime() val end = System.nanoTime()
Benchmarker.mark(Benchmark.DFA, end - start, 0) Benchmarker.mark(Benchmark.DFA, end - start, 0)
} }
}
private fun usesTypeResolution(languageVersion: LanguageVersion, rootNode: Node, ruleSets: RuleSets) { private fun usesTypeResolution(languageVersion: LanguageVersion, rootNode: Node, ruleSets: RuleSets) {
if (ruleSets.usesTypeResolution(languageVersion.language)) { if (ruleSets.usesTypeResolution(languageVersion.language)) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 354 B

@ -4,9 +4,7 @@
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<rule ref="rulesets/java/ali-concurrent.xml"> <rule ref="rulesets/java/ali-concurrent.xml"/>
<exclude name="AvoidCallStaticSimpleDateFormatRule"/>
</rule>
<rule ref="rulesets/java/ali-comment.xml"/> <rule ref="rulesets/java/ali-comment.xml"/>
<rule ref="rulesets/java/ali-naming.xml"> <rule ref="rulesets/java/ali-naming.xml">
<exclude name="ArrayNamingShouldHaveBracketRule"/> <exclude name="ArrayNamingShouldHaveBracketRule"/>

@ -11,6 +11,8 @@ import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.Generated;
import com.alibaba.p3c.pmd.lang.java.util.NumberConstants; import com.alibaba.p3c.pmd.lang.java.util.NumberConstants;
import com.alibaba.p3c.pmd.lang.java.util.StringAndCharConstants; import com.alibaba.p3c.pmd.lang.java.util.StringAndCharConstants;
@ -77,6 +79,7 @@ import net.sourceforge.pmd.lang.java.typeresolution.PMDASMClassLoader;
* @author unknown * @author unknown
* @date 2016/11/21 * @date 2016/11/21
*/ */
@Generated("from pmd")
public class FixClassTypeResolver extends ClassTypeResolver { public class FixClassTypeResolver extends ClassTypeResolver {
private static final Logger LOG = Logger.getLogger(FixClassTypeResolver.class.getName()); private static final Logger LOG = Logger.getLogger(FixClassTypeResolver.class.getName());

@ -39,6 +39,8 @@ public class TransactionMustHaveRollbackRule extends AbstractAliRule {
+ TRANSACTIONAL_ANNOTATION_NAME; + TRANSACTIONAL_ANNOTATION_NAME;
private static final String ROLLBACK_PREFIX = "rollback"; private static final String ROLLBACK_PREFIX = "rollback";
private static final String PROPAGATION_NOT_SUPPORTED = "Propagation.NOT_SUPPORTED";
private static final String XPATH_FOR_ROLLBACK = "//StatementExpression/PrimaryExpression" private static final String XPATH_FOR_ROLLBACK = "//StatementExpression/PrimaryExpression"
+ "/PrimaryPrefix/Name[ends-with(@Image,'rollback')]"; + "/PrimaryPrefix/Name[ends-with(@Image,'rollback')]";
@ -53,7 +55,7 @@ public class TransactionMustHaveRollbackRule extends AbstractAliRule {
return super.visit(node, data); return super.visit(node, data);
} }
List<ASTMemberValuePair> memberValuePairList = node.findDescendantsOfType(ASTMemberValuePair.class); List<ASTMemberValuePair> memberValuePairList = node.findDescendantsOfType(ASTMemberValuePair.class);
if (rollbackAttrSet(memberValuePairList)) { if (shouldSkip(memberValuePairList)) {
return super.visit(node, data); return super.visit(node, data);
} }
@ -80,9 +82,16 @@ public class TransactionMustHaveRollbackRule extends AbstractAliRule {
return super.visit(node, data); return super.visit(node, data);
} }
private boolean rollbackAttrSet(List<ASTMemberValuePair> memberValuePairList) { private boolean shouldSkip(List<ASTMemberValuePair> memberValuePairList) {
for (ASTMemberValuePair pair : memberValuePairList) { for (ASTMemberValuePair pair : memberValuePairList) {
if (pair.getImage() != null && pair.getImage().startsWith(ROLLBACK_PREFIX)) { if (pair.getImage() == null) {
continue;
}
if (pair.getImage().startsWith(ROLLBACK_PREFIX)) {
return true;
}
ASTName name = pair.getFirstDescendantOfType(ASTName.class);
if (name != null && PROPAGATION_NOT_SUPPORTED.equals(name.getImage())) {
return true; return true;
} }
} }

Loading…
Cancel
Save