Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

PMD Class Check

David Tas
2008-04-17
2013-05-20
  • David Tas
    David Tas
    2008-04-17

    I have the following class:

    class Foo{
        static final Logger log = Logger.getLogger(Foo.class.getName());
    }

    I want to implement a rule that checks the argument of Logger.getLogger is "Clazz".class.getName(), no matter which class "Clazz" is.
    How does that rule have to look like?

     
    • David Tas
      David Tas
      2008-04-17

      I tried with

      //Statement[ancestor::MethodDeclaration]/StatementExpression/PrimaryExpression/PrimaryPrefix[starts-with(Name/@Image, 'Logger')]/../PrimarySuffix/Arguments/ArgumentList/Expression[position() =1]/PrimaryExpression/PrimaryPrefix/ResultType/Type/ReferenceType/ClassOrInterfaceType[@Image!=ancestor::ClassOrInterfaceDeclaration/@Image)]]

      but it doesn't work...