Checkstyle - Exclude folder

前端 未结 3 1737
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 20:57

I want to ignore a specific folder (named generated-sources) from my checkstyle reports, because they are generated.

I\'m using eclipse-cs for displaying my violatio

相关标签:
3条回答
  • 2021-01-03 21:22
    <suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
    

    this works :)

    0 讨论(0)
  • 2021-01-03 21:26

    Additionally to the answer from Philipp, I had to use an absolute pathname ( :-( ) for the suppression file:

    <module name="SuppressionFilter">
        <property name="file" value="/Users/xxx/workspace/suppressions.xml"/>
    </module>
    

    Looks like the Checkstyle plugin is not using the project home directory.

    (at least under eclipse luna / Mac OS X)

    0 讨论(0)
  • 2021-01-03 21:38

    As pointed by Thomas Welsch in his answer, there appears to be a problem with using relative pathname for the suppression xml file.

    For gradle builds, This gist suggests a workaround:

    in build.gradle:

    checkstyle {
        // use one common config file for all subprojects
        configFile = project(':').file('config/checkstyle/checkstyle.xml')
        configProperties = [ "suppressionFile" : project(':').file('config/checkstyle/suppressions.xml')]
     }
    

    in checkstyle.xml:

    <module name="SuppressionFilter">
        <property name="file" value="${suppressionFile}" default="suppressions.xml"/>
    </module>
    

    (the default value allows IDE plugins, that do not have the gradle variable sorted out, to work correctly)

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