Generating Checkstyle Reports (with extended checks)

人盡茶涼 提交于 2019-12-02 03:29:55

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!