Generating Checkstyle Reports (with extended checks)

后端 未结 1 1456
梦谈多话
梦谈多话 2021-01-23 15:55

I have some own extended checks. I have exported them as plug-in and in Eclipse, they are showing warning/error. So the extended checks are working fine.

Now I want to g

相关标签:
1条回答
  • 2021-01-23 16:44

    I have found out the following solution, which is working fine.

    1. extract checkstyle-x.x-all.jar
    2. copy the extended classes in the extracted directory
    3. copy the metadata,message and properties file of extended check in the same directory.
    4. if any of the file is alreasy present, then edit the file and add the content from extended checks.
    5. create a new .jar file including all these.
    6. in ant build.xml <taskdef>, set this .jar as classpath

    Like, after done till 2nd step, I found checkstyle_packages.xml is already present, so I edit it and added the content from extended one in proper position.


    Previous Version:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE checkstyle-packages PUBLIC
        "-//Puppy Crawl//DTD Package Names 1.0//EN"
        "http://www.puppycrawl.com/dtds/packages_1_0.dtd">
    
    <checkstyle-packages>
      <package name="com.puppycrawl.tools.checkstyle">
        <package name="checks">
          <package name="annotation"/>
          <package name="blocks"/>
          <package name="coding"/>
          <package name="design"/>
          <package name="duplicates"/>
          <package name="header"/>
          <package name="imports"/>
          <package name="indentation"/>
          <package name="javadoc"/>
          <package name="metrics"/>
          <package name="modifier"/>
          <package name="naming"/>
          <package name="regexp"/>
          <package name="sizes"/>
          <package name="whitespace"/>
        </package>
        <package name="filters"/>
      </package>
    </checkstyle-packages>
    

    Changed Version:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE checkstyle-packages PUBLIC
        "-//Puppy Crawl//DTD Package Names 1.0//EN"
        "http://www.puppycrawl.com/dtds/packages_1_0.dtd">
    
    <checkstyle-packages>
      <package name="com.puppycrawl.tools.checkstyle">
        <package name="checks">
          <package name="annotation"/>
          <package name="blocks"/>
          <package name="coding"/>
          <package name="design"/>
          <package name="duplicates"/>
          <package name="header"/>
          <package name="imports"/>
          <package name="indentation"/>
          <package name="javadoc"/>
          <package name="metrics"/>
          <package name="modifier"/>
          <package name="naming"/>
          <package name="regexp"/>
          <package name="sizes"/>
          <package name="whitespace"/>
        </package>
        <package name="filters"/>
      </package>
    
      <!-- Added this lines -->
      <package name="myCheck">
        <package name="checks"/>
      </package>
      <!--                  -->
    
    </checkstyle-packages>
    

    now the build file is running successfully and in the report I'm getting violation of extended checks too.

    0 讨论(0)
提交回复
热议问题