Checkstyle publisher did not honor 0 values
The Checkstyle publisher would not honor value of 0 and instead emit an empty XML element. This was due to the 'if someval' which would be false whenever someval is 0. Adjusted tests to match the new (and correct) behavior. While at it slightly simplified the repeating logic in checkstyle publisher. Change-Id: I7443b93aa116dc049de565ff96ca40526b390409
This commit is contained in:
parent
8b8745586e
commit
30598272f6
@ -1075,18 +1075,10 @@ def checkstyle(parser, xml_parent, data):
|
||||
'hudson.plugins.checkstyle.'
|
||||
'CheckStylePublisher')
|
||||
|
||||
dval = data.get('healthy', None)
|
||||
if dval:
|
||||
XML.SubElement(checkstyle, 'healthy').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(checkstyle, 'healthy')
|
||||
|
||||
dval = data.get('unHealthy', None)
|
||||
if dval:
|
||||
XML.SubElement(checkstyle, 'unHealthy').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(checkstyle, 'unHealthy')
|
||||
|
||||
XML.SubElement(checkstyle, 'healthy').text = str(
|
||||
data.get('healthy', ''))
|
||||
XML.SubElement(checkstyle, 'unHealthy').text = str(
|
||||
data.get('unHealthy', ''))
|
||||
XML.SubElement(checkstyle, 'thresholdLimit').text = \
|
||||
data.get('healthThreshold', 'low')
|
||||
|
||||
@ -1095,10 +1087,8 @@ def checkstyle(parser, xml_parent, data):
|
||||
XML.SubElement(checkstyle, 'defaultEncoding').text = \
|
||||
data.get('defaultEncoding', '')
|
||||
|
||||
if data.get('canRunOnFailed', False):
|
||||
XML.SubElement(checkstyle, 'canRunOnFailed').text = 'true'
|
||||
else:
|
||||
XML.SubElement(checkstyle, 'canRunOnFailed').text = 'false'
|
||||
XML.SubElement(checkstyle, 'canRunOnFailed').text = str(
|
||||
data.get('canRunOnFailed', False)).lower()
|
||||
|
||||
XML.SubElement(checkstyle, 'useStableBuildAsReference').text = 'false'
|
||||
|
||||
@ -1109,58 +1099,26 @@ def checkstyle(parser, xml_parent, data):
|
||||
dfailed = dthresholds.get('failed', {})
|
||||
thresholds = XML.SubElement(checkstyle, 'thresholds')
|
||||
|
||||
dval = dunstable.get('totalAll', None)
|
||||
if dval:
|
||||
XML.SubElement(thresholds, 'unstableTotalAll').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(thresholds, 'unstableTotalAll')
|
||||
XML.SubElement(thresholds, 'unstableTotalAll').text = str(
|
||||
dunstable.get('totalAll', ''))
|
||||
XML.SubElement(thresholds, 'unstableTotalHigh').text = str(
|
||||
dunstable.get('totalHigh', ''))
|
||||
XML.SubElement(thresholds, 'unstableTotalNormal').text = str(
|
||||
dunstable.get('totalNormal', ''))
|
||||
XML.SubElement(thresholds, 'unstableTotalLow').text = str(
|
||||
dunstable.get('totalLow', ''))
|
||||
|
||||
dval = dunstable.get('totalHigh', None)
|
||||
if dval:
|
||||
XML.SubElement(thresholds, 'unstableTotalHigh').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(thresholds, 'unstableTotalHigh')
|
||||
XML.SubElement(thresholds, 'failedTotalAll').text = str(
|
||||
dfailed.get('totalAll', ''))
|
||||
XML.SubElement(thresholds, 'failedTotalHigh').text = str(
|
||||
dfailed.get('totalHigh', ''))
|
||||
XML.SubElement(thresholds, 'failedTotalNormal').text = str(
|
||||
dfailed.get('totalNormal', ''))
|
||||
XML.SubElement(thresholds, 'failedTotalLow').text = str(
|
||||
dfailed.get('totalLow', ''))
|
||||
|
||||
dval = dunstable.get('totalNormal', None)
|
||||
if dval:
|
||||
XML.SubElement(thresholds, 'unstableTotalNormal').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(thresholds, 'unstableTotalNormal')
|
||||
|
||||
dval = dunstable.get('totalLow', None)
|
||||
if dval:
|
||||
XML.SubElement(thresholds, 'unstableTotalLow').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(thresholds, 'unstableTotalLow')
|
||||
|
||||
dval = dfailed.get('totalAll', None)
|
||||
if dval:
|
||||
XML.SubElement(thresholds, 'failedTotalAll').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(thresholds, 'failedTotalAll')
|
||||
|
||||
dval = dfailed.get('totalHigh', None)
|
||||
if dval:
|
||||
XML.SubElement(thresholds, 'failedTotalHigh').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(thresholds, 'failedTotalHigh')
|
||||
|
||||
dval = dfailed.get('totalNormal', None)
|
||||
if dval:
|
||||
XML.SubElement(thresholds, 'failedTotalNormal').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(thresholds, 'failedTotalNormal')
|
||||
|
||||
dval = dfailed.get('totalLow', None)
|
||||
if dval:
|
||||
XML.SubElement(thresholds, 'failedTotalLow').text = str(dval)
|
||||
else:
|
||||
XML.SubElement(thresholds, 'failedTotalLow')
|
||||
|
||||
if data.get('shouldDetectModules', False):
|
||||
XML.SubElement(checkstyle, 'shouldDetectModules').text = 'true'
|
||||
else:
|
||||
XML.SubElement(checkstyle, 'shouldDetectModules').text = 'false'
|
||||
XML.SubElement(checkstyle, 'shouldDetectModules').text = \
|
||||
str(data.get('shouldDetectModules', False)).lower()
|
||||
|
||||
XML.SubElement(checkstyle, 'dontComputeNew').text = 'true'
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.checkstyle.CheckStylePublisher>
|
||||
<healthy/>
|
||||
<healthy>0</healthy>
|
||||
<unHealthy>100</unHealthy>
|
||||
<thresholdLimit>high</thresholdLimit>
|
||||
<pluginName>[CHECKSTYLE] </pluginName>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.checkstyle.CheckStylePublisher>
|
||||
<healthy/>
|
||||
<healthy>0</healthy>
|
||||
<unHealthy>100</unHealthy>
|
||||
<thresholdLimit>high</thresholdLimit>
|
||||
<pluginName>[CHECKSTYLE] </pluginName>
|
||||
|
Loading…
Reference in New Issue
Block a user