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:
violations() {
jslint(0, 1, 1, 'test-report/*.xml')
}
then one gets a jslint entry specifying a min of 10, not 0:
<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:
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.
|