#246 Settable maxViolations [ANT]

release_3.5
closed
5
2012-10-10
2003-08-05
David Hibbs
No

I was thinking that it would be useful to be able to set
up checkstyle checks that will typically force a build
failure, but can be given "reasonable exception" passage
by peers. So it seems to me that there is an easy way
to do this--allow an additional Ant task property
of "maxViolations" (defaulted to zero) and use that
property as an additional control on failure conditions. It
looks like it should be easy to implement, given the
following code snippet from viewCVS of CheckStyleTask:

// Handle the return status
if ((numErrs > 0) && mFailureProperty != null)
{
getProject().setProperty(mFailureProperty, "true");
}

if ((numErrs > 0) && mFailOnViolation)
{
throw new BuildException("Got " + numErrs + "
errors.",
getLocation());
}

Instead of comparing to zero, compare against
maxViolations:

// Handle the return status
if ((numErrs > maxViolations) && mFailureProperty !=
null)
{
getProject().setProperty(mFailureProperty, "true");
}

if ((numErrs > maxViolations) && mFailOnViolation)
{
throw new BuildException("Got " + numErrs + "
errors.",
getLocation());
}

Discussion

  • David Ufton

    David Ufton - 2003-11-15

    Logged In: YES
    user_id=787032

    We use checkstyle on cvs commit to prevent source code that
    fails the checks being deposited in the repository. While
    I'm happy that any error causes a failure which prevents the
    commit, I would like to be able to use the warnings more
    effectively - one useful feature would to be able to
    configure the number of warnings required before a
    checkstyle failure.

     
  • Lars Kühne

    Lars Kühne - 2004-04-12

    Logged In: YES
    user_id=401384

    New Ant task attributes 'maxErrors' and 'maxWarnings' have
    been implemented in CVS and will be part of the next release.

     
  • Lars Kühne

    Lars Kühne - 2004-10-16

    Logged In: YES
    user_id=401384

    Oops, forgot to close this request...

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks