klaasnicolaas/python-omnikinverter

View on GitHub

Showing 8 of 8 total issues

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

    def from_js(data: str) -> Inverter:
        """Return Inverter object from the Omnik Inverter response.

        Args:
        ----
Severity: Minor
Found in src/omnikinverter/models.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

File tcp.py has 258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Data model and conversions for tcp-based communication with the Omnik Inverter."""

from __future__ import annotations

from ctypes import BigEndianStructure, c_char, c_ubyte, c_uint, c_ushort, sizeof
Severity: Minor
Found in src/omnikinverter/tcp.py - About 2 hrs to fix

    Function parse has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse(cls, data: bytes, offset: int = 0) -> dict[str, Any]:
            """Parse `data` into all fields described by this C structure."""
            tcp_data = cls.from_buffer_copy(data, offset)
    
            if tcp_data.unknown0 not in [0, UINT16_MAX]:  # pragma: no cover
    Severity: Minor
    Found in src/omnikinverter/tcp.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

    File models.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Models for Omnik Inverter."""
    
    from __future__ import annotations
    
    import re
    Severity: Minor
    Found in src/omnikinverter/models.py - About 2 hrs to fix

      Function from_html has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_html(data: str) -> Inverter:
              """Return Inverter object from the Omnik Inverter response.
      
              Args:
              ----
      Severity: Minor
      Found in src/omnikinverter/models.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 _unpack_messages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def _unpack_messages(
          data: bytearray,
      ) -> Generator[tuple[int, int, bytearray], None, None]:
          while len(data):
              message_start = data.pop(0)
      Severity: Minor
      Found in src/omnikinverter/tcp.py - About 55 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 from_html has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_html(data: str) -> Device:
              """Return Device object from the Omnik Inverter response.
      
              Args:
              ----
      Severity: Minor
      Found in src/omnikinverter/models.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

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

          def from_js(data: str) -> Device:
              """Return Device object from the Omnik Inverter response.
      
              Args:
              ----
      Severity: Minor
      Found in src/omnikinverter/models.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