Git Product home page Git Product logo

Comments (5)

dykov avatar dykov commented on June 19, 2024
//ClassOrInterfaceDeclaration
[pmd-java:typeIs('java.lang.Exception')] (: extends Exception class :)
[
not(
./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration/FormalParameters[
    (: Ctor(Throwable, String, Object...) :)
    (./FormalParameter[1]/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Throwable')]
    and
    ./FormalParameter[2]/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('java.lang.String')]
    and
    ./FormalParameter[3][@Varargs=true()]/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIsExactly('java.lang.Object')])

    or

    (: Ctor(String, Object...) :)
    (./FormalParameter[1]/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('java.lang.String')]
    and
    ./FormalParameter[2][@Varargs=true()]/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIsExactly('java.lang.Object')])] (: typeIs('java.lang.Object') can accept any class :)
)
]

from arch4u-pmd.

dykov avatar dykov commented on June 19, 2024

@dgroup , should the rule throw violation for the following case?

class MyException extends Exception {
    public MyException(Exception cause, String pattern, Object... args) {
    }
}

Here we have Exception as a first constructor param, not Throwable

from arch4u-pmd.

dykov avatar dykov commented on June 19, 2024

@dgroup , also should these constructors have strictly public modifier?

from arch4u-pmd.

dgroup avatar dgroup commented on June 19, 2024

Not sure about public, let's do not check it so far

from arch4u-pmd.

dykov avatar dykov commented on June 19, 2024

@dgroup, so i suggest to check for non-private modifier?

from arch4u-pmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.