timeyyy/pytknvim

View on GitHub
pytknvim/tk_ui.py

Summary

Maintainability
D
2 days
Test Coverage

File tk_ui.py has 490 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'''
Implements a UI for neovim  using tkinter.

* The widget has lines updated/deleted so that any
  given time it only contains what is being displayed.
Severity: Minor
Found in pytknvim/tk_ui.py - About 7 hrs to fix

    Function _get_tk_attrs has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_tk_attrs(self, attrs):
            key = tuple(sorted((k, v,) for k, v in (attrs or {}).items()))
            rv = self._tk_attrs_cache.get(key, None)
            if rv is None:
                fg = self._foreground if self._foreground != -1\
    Severity: Minor
    Found in pytknvim/tk_ui.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

    NvimHandler has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class NvimHandler(MixTk):
        '''These methods get called by neovim'''
    
        def __init__(self, text, toplevel, address=-1, debug_echo=False):
            self.text = text
    Severity: Minor
    Found in pytknvim/tk_ui.py - About 3 hrs to fix

      Function _flush has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def _flush(self):
              row, startcol, endcol = self._pending
              self._pending[0] = self._screen.row
              self._pending[1] = self._screen.col
              self._pending[2] = self._screen.col
      Severity: Minor
      Found in pytknvim/tk_ui.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 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, parent, *_, address=False, toplevel=False, **kwargs):
      Severity: Minor
      Found in pytknvim/tk_ui.py - About 35 mins to fix

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

            def _draw(self, row, col, data):
                '''
                updates a line :)
                '''
                for text, attrs in data:
        Severity: Minor
        Found in pytknvim/tk_ui.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 tk_key_pressed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def tk_key_pressed(self,event, **k):
                keysym = event.keysym
                state = parse_tk_state(event.state)
                if event.char not in ('', ' ') \
                            and state in (None, 'Shift'):
        Severity: Minor
        Found in pytknvim/tk_ui.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

        There are no issues that match your filters.

        Category
        Status