diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/android/xml/CallSuperFirst.xml b/pmd/regress/test/net/sourceforge/pmd/rules/android/xml/CallSuperFirst.xml index 9ae1745d31..38e490e56c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/android/xml/CallSuperFirst.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/android/xml/CallSuperFirst.xml @@ -17,6 +17,34 @@ public class MyActivity extends Activity { + 0 + + + + 1 diff --git a/pmd/rulesets/android.xml b/pmd/rulesets/android.xml index c6c86b96be..f7450f3239 100644 --- a/pmd/rulesets/android.xml +++ b/pmd/rulesets/android.xml @@ -12,10 +12,10 @@ To get better results, make sure that the auxclasspath is defined for type resol - Super must be called at the start of the method + Super should be called at the start of the method 3 @@ -30,8 +30,14 @@ To get better results, make sure that the auxclasspath is defined for type resol @Image='onResume' or @Image='onStart' ]] - /Block/BlockStatement[1] - [not(Statement/StatementExpression/PrimaryExpression/PrimaryPrefix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image])] + /Block[not( + (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image]) or + ((BlockStatement[1]/Statement/IfStatement/Expression[ + PrimaryExpression/PrimaryPrefix/Name[@Image='Config.LOGD' or @Image='Config.LOGV'] + or + ConditionalAndExpression/PrimaryExpression/PrimaryPrefix/Name[@Image='Config.LOGD' or @Image='Config.LOGV'] + ]) and + (BlockStatement[2]/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image])))] [ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[ typeof(@Image, 'android.app.Activity', 'Activity') or typeof(@Image, 'android.app.Application', 'Application') or @@ -54,10 +60,10 @@ To get better results, make sure that the auxclasspath is defined for type resol - Super must be called at the end of the method + Super should be called at the end of the method 3 @@ -94,10 +100,10 @@ To get better results, make sure that the auxclasspath is defined for type resol - Log.d must be protected by checking Config.LOGD + Log.d calls should be protected by checking Config.LOGD first 3 @@ -129,10 +135,10 @@ To get better results, make sure that the auxclasspath is defined for type resol - Log.v must be protected by checking Config.LOGV + Log.v calls should be protected by checking Config.LOGV first 3