#383 maxWarnings and maxErrors has no effect on CheckStyle

release_4.0
closed
Lars Kühne
ANT Task (45)
5
2015-01-15
2005-10-19
No

I have a source tree which contains over 250,000 coding
violations based on the sun_check guidelines. In an
attempt to reduce the reported number so that the xslt
task can complete and the html files are small enough
to view, I set maxWarnings and maxErrors to 10,000. I
still got over 250,000 violations.

I then set maxErrors and maxWarnings to 1. I still get
over 250,000 violations. Here is my ant target:

<target name="checkstyle" depends="prepare">
<taskdef resource="checkstyletask.properties"
     classpath="${checkstyle.jar}">
</taskdef>

<checkstyle config="${checkstyle.file}"

failureProperty="checkstyle.failure"
failOnViolation="true"
classpathref="runtime.classpath"
maxWarnings="1" maxErrors="1">
<fileset dir="${source.home}" includes="**/*.java"/>
<formatter type="xml" toFile="${reports.style}/checkstyle_report.xml"/>
</checkstyle>

<style in="${reports.style}/checkstyle_report.xml" 
       out="${reports.style}/html/checkstyle_report.html" 
       style="${common.home}/checkstyle-frames.xsl">
    <factory

name="org.apache.xalan.processor.TransformerFactoryImpl">
<attribute name="http://xml.apache.org/xalan/features/optimize" value="true"/>
<attribute name="http://xml.apache.org/xalan/features/incremental" value="true"/>
</factory>
</style>
</target>

Discussion

  • Lars Kühne
    Lars Kühne
    2005-10-20

    Logged In: YES
    user_id=401384

    Please check the documentation for maxWarnings/Errors, these
    parameters do not control how many errors are reported to
    the XML file. Their purpose is to control when to break the
    build, i.e. abort the build inside the Checkstyle Ant task.

    What I don't understand is that you seem to set
    failOnViolation to true and set the limit to 1, and
    checkstyle reports violations but still the build doesn't
    break? This shouldn't be the case. Is the style task really
    called?

    As for solving your <style> runtime problem, there are two
    typical ways to introduce checkstyle into an existing code base:
    a) check only parts of the code, e.g. by focusing on certain
    packages in the fileset.
    b) change the configuration to suit your needs.

    In your case I would go for option b. Unless you have a
    really HUGE code base, 250000 errors are typically generated
    only if your code violates a really basic config option,
    like indentation with tabs, position of opening curly brace,
    etc. Have a look at the XML file to find out which violation
    is reposonsible for the majority of entries and temporarily
    remove the corresponding check from the configuration.

     
  • Logged In: YES
    user_id=1312539

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).