robbinjanssen/python-ojmicroline-thermostat

View on GitHub

Showing 17 of 17 total issues

File ojmicroline.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Asynchronous Python client communicating with the OJ Microline API."""

from __future__ import annotations

import asyncio
Severity: Minor
Found in ojmicroline_thermostat/ojmicroline.py - About 2 hrs to fix

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

        def get_target_temperature(self) -> int:
            """Return the target temperature for the thermostat.
    
            Returns
            -------
    Severity: Minor
    Found in ojmicroline_thermostat/models/thermostat.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 from_json has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_json(cls, data: dict[str, Any]) -> Schedule:
            """Return a new Schedule instance based on the given JSON.
    
            Args:
            ----
    Severity: Minor
    Found in ojmicroline_thermostat/models/schedule.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in ojmicroline_thermostat/wd5.py - About 45 mins to fix

      Function get_lowest_temperature has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_lowest_temperature(self) -> int:
              """Get the lowest temperature.
      
              Returns the lowest temperature based on the
              schedule. It is used for eco mode.
      Severity: Minor
      Found in ojmicroline_thermostat/models/schedule.py - About 45 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

      Function update_regulation_mode_body has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_regulation_mode_body(  # noqa: D102
              self,
              thermostat: Thermostat,
              regulation_mode: int,
              temperature: int | None,
      Severity: Minor
      Found in ojmicroline_thermostat/wd5.py - About 45 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

      Function update_regulation_mode_body has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def update_regulation_mode_body(  # noqa: D102
      Severity: Minor
      Found in ojmicroline_thermostat/wd5.py - About 35 mins to fix

        Function update_regulation_mode_body has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def update_regulation_mode_body(  # noqa: D102
        Severity: Minor
        Found in ojmicroline_thermostat/wg4.py - About 35 mins to fix

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

              def parse_thermostats_response(self, data: Any) -> list[Thermostat]:  # noqa: D102
                  if data["ErrorCode"] == 1:
                      msg = "Unable to get thermostats via API."
                      raise OJMicrolineResultsError(msg, {"data": data})
          
          
          Severity: Minor
          Found in ojmicroline_thermostat/wd5.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

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

              def get_current_temperature(self) -> int:
                  """Return the current temperature for the thermostat.
          
                  For WD5-series thermostats, the current temperature based on the
                  sensor type. If it is set to room/floor, then the average is used.
          Severity: Minor
          Found in ojmicroline_thermostat/models/thermostat.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 self.frost_protection_temperature or 0
          Severity: Major
          Found in ojmicroline_thermostat/models/thermostat.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return self.boost_temperature or 0
            Severity: Major
            Found in ojmicroline_thermostat/models/thermostat.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return Schedule.from_json(self.schedule).get_lowest_temperature()
              Severity: Major
              Found in ojmicroline_thermostat/models/thermostat.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return self.vacation_temperature or 0
                Severity: Major
                Found in ojmicroline_thermostat/models/thermostat.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return 0
                  Severity: Major
                  Found in ojmicroline_thermostat/models/thermostat.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return 0
                    Severity: Major
                    Found in ojmicroline_thermostat/models/thermostat.py - About 30 mins to fix

                      Function parse_thermostats_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def parse_thermostats_response(self, data: Any) -> list[Thermostat]:  # noqa: D102
                              results: list[Thermostat] = []
                              for group in data["Groups"]:
                                  for item in group["Thermostats"]:
                                      if len(item):
                      Severity: Minor
                      Found in ojmicroline_thermostat/wg4.py - About 25 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

                      Severity
                      Category
                      Status
                      Source
                      Language