custom check -cannot get it working

16 views
Skip to first unread message

shivakumar pullepu

unread,
Dec 15, 2020, 9:16:20 PM12/15/20
to checkstyle
@guys, I am simply trying to make this  https://checkstyle.sourceforge.io/writingchecks.html#Integrate_your_Check work on my local environment. I cannot get it working 

Error I am seeing 
C:\Users\customcheck>java -classpath customcheck.jar;checkstyle-8.38-all.jar com.puppycrawl.tools.checkstyle.Main -c config.xml .
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - cannot initialize module com.mycompany.checks.MethodLimitCheck - Unable to instantiate com.mycompany.checks.Met
hodLimitCheck
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:482)
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:201)
        at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:404)
        at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:331)
        at com.puppycrawl.tools.checkstyle.Main.execute(Main.java:190)
        at com.puppycrawl.tools.checkstyle.Main.main(Main.java:125)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module com.mycompany.checks.MethodLimitCheck - Unable to instantiate com.mycompany.checks.MethodLimitCheck
        at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:125)
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:201)
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:477)
        ... 5 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate com.mycompany.checks.MethodLimitCheck
        at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createObject(PackageObjectFactory.java:370)
        at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:198)
        at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:116)
        ... 7 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createObject(PackageObjectFactory.java:367)
        ... 9 more
Caused by: java.lang.Error: Unresolved compilation problems:
        The import com.puppycrawl cannot be resolved
        AbstractCheck cannot be resolved to a type
        The method getDefaultTokens() of type MethodLimitCheck must override or implement a supertype method
        TokenTypes cannot be resolved to a variable
        TokenTypes cannot be resolved to a variable
        DetailAST cannot be resolved to a type
        DetailAST cannot be resolved to a type
        TokenTypes cannot be resolved to a variable
        TokenTypes cannot be resolved to a variable

My local code is posted in here, any help is much appreciated. 



Roman Ivanov

unread,
Dec 15, 2020, 10:28:59 PM12/15/20
to shivakumar pullepu, checkstyle
You have compilation problem in your project
Please review https://github.com/sevntu-checkstyle/sevntu.checkstyle/tree/master/sevntu-checks project as example of project with bunch of custom Checks.

--
You received this message because you are subscribed to the Google Groups "checkstyle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to checkstyle+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/checkstyle/a9be8655-137b-4f54-8f51-3dbe582ff8fen%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages