Issue Type: Bug Bug
Assignee: Daniel Spilker
Components: job-dsl-plugin
Created: 16/Dec/14 4:04 PM
Description:

ViolationsContext.groovy doesn't differentiate between an integer zero and no integer being supplied.
This means that if you specify a zero in your configuration, the code supplies the default value instead.

e.g. if one uses the configuration:

example.groovy
violations() {
   jslint(0, 1, 1, 'test-report/*.xml')
}

then one gets a jslint entry specifying a min of 10, not 0:

snippet.xml
<entry>
    <string>jslint</string>
    <hudson.plugins.violations.TypeConfig>
        <type>jslint</type>
        <min>10</min>
        <max>1</max>
        <unstable>1</unstable>
        <usePattern>true</usePattern>
        <pattern>test-report/*.xml</pattern>
    </hudson.plugins.violations.TypeConfig>
</entry>

i.e. the code provided a "min" value of 0, but the resulting XML says 10.


I suspect that this is because ViolationsContext.groovy method createEntry(...) lines 34-36 use the ?: operator to decide whether or not to use a default value:

ViolationsContext.snippet.groovy
private createEntry(Integer min = null, Integer max = null, Integer unstable = null, String pattern = null) {
    new ViolationsEntry(
            min: min ?: 10,
            max: max ?: 999,
            unstable: unstable ?: 999,
            pattern: pattern)
}

This means that createEntry() will return the same as createEntry(0,0,0,''), which means that if you specify min=0 then you get a min of 10, and I rather wanted to specify a min of 0...

I suspect that the line "min: min ?: 10," should be something like "min: min==null ? 10 : min," so it only gives a default value of min if a null value is given, not merely a "false" value.

Project: Jenkins
Priority: Minor Minor
Reporter: pjdarton
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to