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.'
|
'hudson.plugins.checkstyle.'
|
||||||
'CheckStylePublisher')
|
'CheckStylePublisher')
|
||||||
|
|
||||||
dval = data.get('healthy', None)
|
XML.SubElement(checkstyle, 'healthy').text = str(
|
||||||
if dval:
|
data.get('healthy', ''))
|
||||||
XML.SubElement(checkstyle, 'healthy').text = str(dval)
|
XML.SubElement(checkstyle, 'unHealthy').text = str(
|
||||||
else:
|
data.get('unHealthy', ''))
|
||||||
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, 'thresholdLimit').text = \
|
XML.SubElement(checkstyle, 'thresholdLimit').text = \
|
||||||
data.get('healthThreshold', 'low')
|
data.get('healthThreshold', 'low')
|
||||||
|
|
||||||
@ -1095,10 +1087,8 @@ def checkstyle(parser, xml_parent, data):
|
|||||||
XML.SubElement(checkstyle, 'defaultEncoding').text = \
|
XML.SubElement(checkstyle, 'defaultEncoding').text = \
|
||||||
data.get('defaultEncoding', '')
|
data.get('defaultEncoding', '')
|
||||||
|
|
||||||
if data.get('canRunOnFailed', False):
|
XML.SubElement(checkstyle, 'canRunOnFailed').text = str(
|
||||||
XML.SubElement(checkstyle, 'canRunOnFailed').text = 'true'
|
data.get('canRunOnFailed', False)).lower()
|
||||||
else:
|
|
||||||
XML.SubElement(checkstyle, 'canRunOnFailed').text = 'false'
|
|
||||||
|
|
||||||
XML.SubElement(checkstyle, 'useStableBuildAsReference').text = 'false'
|
XML.SubElement(checkstyle, 'useStableBuildAsReference').text = 'false'
|
||||||
|
|
||||||
@ -1109,58 +1099,26 @@ def checkstyle(parser, xml_parent, data):
|
|||||||
dfailed = dthresholds.get('failed', {})
|
dfailed = dthresholds.get('failed', {})
|
||||||
thresholds = XML.SubElement(checkstyle, 'thresholds')
|
thresholds = XML.SubElement(checkstyle, 'thresholds')
|
||||||
|
|
||||||
dval = dunstable.get('totalAll', None)
|
XML.SubElement(thresholds, 'unstableTotalAll').text = str(
|
||||||
if dval:
|
dunstable.get('totalAll', ''))
|
||||||
XML.SubElement(thresholds, 'unstableTotalAll').text = str(dval)
|
XML.SubElement(thresholds, 'unstableTotalHigh').text = str(
|
||||||
else:
|
dunstable.get('totalHigh', ''))
|
||||||
XML.SubElement(thresholds, 'unstableTotalAll')
|
XML.SubElement(thresholds, 'unstableTotalNormal').text = str(
|
||||||
|
dunstable.get('totalNormal', ''))
|
||||||
|
XML.SubElement(thresholds, 'unstableTotalLow').text = str(
|
||||||
|
dunstable.get('totalLow', ''))
|
||||||
|
|
||||||
dval = dunstable.get('totalHigh', None)
|
XML.SubElement(thresholds, 'failedTotalAll').text = str(
|
||||||
if dval:
|
dfailed.get('totalAll', ''))
|
||||||
XML.SubElement(thresholds, 'unstableTotalHigh').text = str(dval)
|
XML.SubElement(thresholds, 'failedTotalHigh').text = str(
|
||||||
else:
|
dfailed.get('totalHigh', ''))
|
||||||
XML.SubElement(thresholds, 'unstableTotalHigh')
|
XML.SubElement(thresholds, 'failedTotalNormal').text = str(
|
||||||
|
dfailed.get('totalNormal', ''))
|
||||||
|
XML.SubElement(thresholds, 'failedTotalLow').text = str(
|
||||||
|
dfailed.get('totalLow', ''))
|
||||||
|
|
||||||
dval = dunstable.get('totalNormal', None)
|
XML.SubElement(checkstyle, 'shouldDetectModules').text = \
|
||||||
if dval:
|
str(data.get('shouldDetectModules', False)).lower()
|
||||||
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, 'dontComputeNew').text = 'true'
|
XML.SubElement(checkstyle, 'dontComputeNew').text = 'true'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.checkstyle.CheckStylePublisher>
|
<hudson.plugins.checkstyle.CheckStylePublisher>
|
||||||
<healthy/>
|
<healthy>0</healthy>
|
||||||
<unHealthy>100</unHealthy>
|
<unHealthy>100</unHealthy>
|
||||||
<thresholdLimit>high</thresholdLimit>
|
<thresholdLimit>high</thresholdLimit>
|
||||||
<pluginName>[CHECKSTYLE] </pluginName>
|
<pluginName>[CHECKSTYLE] </pluginName>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.checkstyle.CheckStylePublisher>
|
<hudson.plugins.checkstyle.CheckStylePublisher>
|
||||||
<healthy/>
|
<healthy>0</healthy>
|
||||||
<unHealthy>100</unHealthy>
|
<unHealthy>100</unHealthy>
|
||||||
<thresholdLimit>high</thresholdLimit>
|
<thresholdLimit>high</thresholdLimit>
|
||||||
<pluginName>[CHECKSTYLE] </pluginName>
|
<pluginName>[CHECKSTYLE] </pluginName>
|
||||||
|
Loading…
Reference in New Issue
Block a user