grm/py-smart-gardena

View on GitHub

Showing 4 of 22 total issues

Function update_devices has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def update_devices(self, location):
        response_data = self.__call_smart_system_get(
            f"{self.SMART_HOST}/v1/locations/{location.id}"
        )
        if len(response_data["data"]["relationships"]["devices"]["data"]) < 1:
Severity: Minor
Found in src/gardena/smart_system.py - About 2 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 __response_has_errors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def __response_has_errors(self, response):
        if response.status_code not in (200, 202):
            r = response.json()
            if 'errors' in r:
                msg = "{r['errors'][0]['title']} - {r['errors'][0]['detail']}"
Severity: Minor
Found in src/gardena/smart_system.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

Function build has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def build(smart_system, device_map):
        if "MOWER" in device_map:
            return Mower(smart_system, device_map)
        elif "SENSOR" in device_map:
            return Sensor(smart_system, device_map)
Severity: Minor
Found in src/gardena/devices/device_factory.py - About 35 mins 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 too many return statements within this function.
Open

                return WaterControl(smart_system, device_map)
Severity: Major
Found in src/gardena/devices/device_factory.py - About 30 mins to fix
    Severity
    Category
    Status
    Source
    Language