I'm trying to write my own logic to parse an XML string and convert it into a Python object. It's requiring me to do a bunch of
attribute1 = xml_element.find('ATTRIBUTE1')
attribute2 = xml_element.find('ATTRIBUTE2')
And then several:
if attribute1 is not None:
obj.attribute1 = attribute1.text
if attribute2 is not None:
obj.attribute2 = attribute2.text
These multiple if statements (there's almost 50), is causing 4D to show low test coverage (I'm not testing each if statement, obviously) and also say my function has high cognitive complexity. Wondering if there's a way to do this without having multiple if statements? (Third party packages are not an option)
Aucun commentaire:
Enregistrer un commentaire