markusressel/barcode-server

View on GitHub

Showing 5 of 5 total issues

Function _code_to_character has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def _code_to_character(self, code: str) -> chr or None:
        character = None

        if len(code) == 5:
            character = code[-1]
Severity: Minor
Found in barcode_server/keyevent_reader.py - About 4 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 _on_key_event has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def _on_key_event(self, code: str, state: int) -> bool:
        if code in ["KEY_ENTER", "KEY_KPENTER"]:
            if state == KeyEvent.key_up:
                # line is finished
                self._reset_modifiers()
Severity: Minor
Found in barcode_server/keyevent_reader.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 read_line has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def read_line(self, input_device: InputDevice) -> str:
        """
        Reads a line
        :param input_device: the device to read from
        :return: line
Severity: Minor
Found in barcode_server/keyevent_reader.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, host: str, port: int = 1883,
Severity: Major
Found in barcode_server/notifier/mqtt.py - About 1 hr to fix

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

        def _find_devices(patterns: List, paths: List[str]) -> Dict[str, InputDevice]:
            """
            # Finds the input device with the name ".*Barcode Reader.*".
            # Could and should be parameterized, of course. Device name as cmd line parameter, perhaps?
            :param patterns: list of patterns to match the device name against
    Severity: Minor
    Found in barcode_server/barcode.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

    Severity
    Category
    Status
    Source
    Language