In the code validating process for doxygen (www.doxygen.nl) recently sonarcloud has been enabled and this gives quite a few warnings in respect to the, derived, python code.
In the category "code smells" the list start with numerous warnings about the python code generated by generateDS (see e.g. https://sonarcloud.io/project/issues?id=doxygen_doxygen&branch=master&resolved=false&types=CODE_SMELL)
I looked a bit deeper into the warning 'Remove the unused local variable "result".' (in the second page of 100 warnings, search for "result").
Looking at the generated code:
~~~
def validate_DoxCompoundKind(self, value):
# Validate type DoxCompoundKind, a restriction on xsd:string.
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
if not isinstance(value, str):
lineno = self.gds_get_node_lineno_()
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
return False
value = value
enumerations = ['class', 'struct', 'union', 'interface', 'protocol', 'category', 'exception', 'service', 'singleton', 'module', 'type', 'file', 'namespace', 'group', 'page', 'example', 'dir', 'concept', 'module'] if value not in enumerations:
lineno = self.gds_get_node_lineno_()
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on DoxCompoundKind' % {"value" : encode_str_2_3(value), "lineno": lineno} )
result = False
which is generated from:
<xsd:simpletype name="DoxCompoundKind">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="class">
<xsd:enumeration value="struct">
<xsd:enumeration value="union">
<xsd:enumeration value="interface">
<xsd:enumeration value="protocol">
<xsd:enumeration value="category">
<xsd:enumeration value="exception">
<xsd:enumeration value="service">
<xsd:enumeration value="singleton">
<xsd:enumeration value="module">
<xsd:enumeration value="type">
<xsd:enumeration value="file">
<xsd:enumeration value="namespace">
<xsd:enumeration value="group">
<xsd:enumeration value="page">
<xsd:enumeration value="example">
<xsd:enumeration value="dir">
<xsd:enumeration value="concept">
<xsd:enumeration value="module">
</xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:enumeration></xsd:restriction>
</xsd:simpletype>
~~~
In the generated code I see a number of things that are a bit strange to me:
- using "return False" and "result = False", probably the later should also read "return False"
- there is no return statement at the end, I would have expected here "return True"
- the, in my eyes, useless assignment "value = value"
(I see also that there is twice the word "module" but this is an error at the doxygen side)
At the moment we use for doxygen generateDS 2.37.15 but the results for the current 2.43.3 (after a quick resulting code inspection are the same).
I attached a compressed tar file with the used input and result files for both mentioned generateDS version.