iacchus/birdears

View on GitHub
src/birdears/interfaces/urwid.py

Summary

Maintainability
D
1 day
Test Coverage

File urwid.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import threading

try:
    import urwid
except ImportError:
Severity: Minor
Found in src/birdears/interfaces/urwid.py - About 3 hrs to fix

    Function __init__ has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, scale, question_tonic_pitch, main_loop=None,
                     keyboard_index=None, *args, **kwargs):
    
            self.main_loop = main_loop
    
    
    Severity: Minor
    Found in src/birdears/interfaces/urwid.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 a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, exercise=None, *args, **kwargs):
    
            self.exercise = exercise
            self.arguments = kwargs
    
    
    Severity: Minor
    Found in src/birdears/interfaces/urwid.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 highlight_key has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def highlight_key(self, element=None):
    
            with LOCK:
    
                # for key in self.key_index.values():
    Severity: Minor
    Found in src/birdears/interfaces/urwid.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__(self, top_widget=None, keyboard=None, bottom_widget=None,
    Severity: Minor
    Found in src/birdears/interfaces/urwid.py - About 45 mins to fix

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

          def __init__(self, scale, question_tonic_pitch, main_loop=None,
      Severity: Minor
      Found in src/birdears/interfaces/urwid.py - About 45 mins to fix

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

            def __init__(self, top="", middle="", bottom="", pitch=None, *args,
        Severity: Minor
        Found in src/birdears/interfaces/urwid.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if self.question.n_input_notes > 1:
                                          self.update_input_display()
          
                                  # these inputs are commands to birdears
                                  else:
          Severity: Major
          Found in src/birdears/interfaces/urwid.py - About 45 mins to fix

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

                def keypress(self, key):
            
                    if key in ('T', 't'):
                        with LOCK:
                            self.loop.screen.clear()
            Severity: Minor
            Found in src/birdears/interfaces/urwid.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 draw_question has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def draw_question(self):
            
                    if self.exercise != 'notename':
                        scale = \
                            ChromaticScale(tonic=self.question.lowest_tonic_pitch.note,
            Severity: Minor
            Found in src/birdears/interfaces/urwid.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

            There are no issues that match your filters.

            Category
            Status