Noah-Huppert/py-i2c-register

View on GitHub

Showing 6 of 22 total issues

Function write has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    def write(self, i2c):
        if Register._write_pattern.match(self.op_mode) is not None:
            bits = {}
            managing_segment = {}
            max_bit_i = 0
Severity: Minor
Found in py_i2c_register/register.py - About 5 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 __str__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __str__(self):
        out = "RegisterList<device_address={}, registers={{\n".format(self.dev_addr)

        for k in self.registers:
            v = self.registers[k]
Severity: Minor
Found in py_i2c_register/register_list.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 set_bits has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def set_bits(self, reg_name, seg_name, bits, write_after=False, write_fn=None):
Severity: Minor
Found in py_i2c_register/register_list.py - About 35 mins to fix

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

        def __init__(self, name, dev_addr, reg_addr, op_mode, segments={}):
    Severity: Minor
    Found in py_i2c_register/register.py - About 35 mins to fix

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

          def set_bits_from_int(self, reg_name, seg_name, val, write_after=False, write_fn=None):
      Severity: Minor
      Found in py_i2c_register/register_list.py - About 35 mins to fix

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

            def read(self, i2c):
                if Register._read_pattern.match(self.op_mode) is not None:
                    # Get number of bytes to read, will raise AssertionError if segments do not create round number of bytes
                    bytes_count = self.len_bytes()
                    read_bytes = []
        Severity: Minor
        Found in py_i2c_register/register.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