resource-watch/prep-nexgddp

View on GitHub
nexgddp/services/xml_service.py

Summary

Maintainability
B
5 hrs
Test Coverage
F
55%

Function get_fields has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def get_fields(xml):
        logging.info('[XMLService] Parsing XML fields')
        fields = {}
        try:
            root = ET.fromstring(xml)
Severity: Minor
Found in nexgddp/services/xml_service.py - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function get_domain has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def get_domain(xml):
        logging.info('[XMLService] Parsing XML domain info')
        domain = {}
        try:
            root = ET.fromstring(xml)
Severity: Minor
Found in nexgddp/services/xml_service.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

                            for field_spec in field.findall('{http://www.opengis.net/swe/2.0}Quantity'):
                                for field_spec_uom in field_spec.findall('{http://www.opengis.net/swe/2.0}uom'):
                                    fields[field_name] = {
                                        'type': 'number',
                                        'uom': field_spec_uom.get('code')
Severity: Major
Found in nexgddp/services/xml_service.py - About 45 mins to fix

    There are no issues that match your filters.

    Category
    Status