timeyyy/pytknvim

View on GitHub

Showing 30 of 30 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

Severity: Major
Found in pytknvim/tarruda.py and 1 other location - About 3 wks to fix
pytknvim/tk_canvas.py on lines 0..281

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 2156.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

Severity: Major
Found in pytknvim/tk_canvas.py and 1 other location - About 3 wks to fix
pytknvim/tarruda.py on lines 0..279

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 2156.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 rate_limited has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def rate_limited(max_per_second, mode='wait', delay_first_call=False):
        """
        Decorator that make functions not be called faster than
    
        set mode to 'kill' to just ignore requests that are faster than the
    Severity: Minor
    Found in pytknvim/util.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

    NvimTk has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class NvimTk(object):
    
        """Wraps all nvim/tk event handling."""
    
        def __init__(self, nvim):
    Severity: Minor
    Found in pytknvim/tarruda.py - About 4 hrs to fix

      NvimTk has 32 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class NvimTk(object):
      
          """Wraps all nvim/tk event handling."""
      
          def __init__(self, nvim):
      Severity: Minor
      Found in pytknvim/tk_canvas.py - About 4 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 _nvim_event_loop has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def _nvim_event_loop(self):
                  def on_setup():
                      self._sem.release()
          
                  def on_request(method, args):
          Severity: Minor
          Found in pytknvim/ui_bridge.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 iter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def iter(self, startrow, endrow, startcol, endcol):
                  """Extract text/attrs at row, startcol-endcol."""
                  for row in range(startrow, endrow + 1):
                      r = self._cells[row]
                      cell = r[startcol]
          Severity: Minor
          Found in pytknvim/screen.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                          if left_to_wait > 0:
                              if mode == 'wait':
                                  time.sleep(left_to_wait)
                                  return run_func()
                              elif mode == 'kill':
          Severity: Major
          Found in pytknvim/util.py and 1 other location - About 1 hr to fix
          pytknvim/util.py on lines 168..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 43.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                          elif left_to_wait > 0:
                              if mode == 'wait':
                                  time.sleep(left_to_wait)
                                  return run_func()
                              elif mode == 'kill':
          Severity: Major
          Found in pytknvim/util.py and 1 other location - About 1 hr to fix
          pytknvim/util.py on lines 151..157

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 43.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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 font_from_style has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def font_from_style(self, name, style):
                  '''configure font attributes'''
                  # Get base font options
                  new_font = tk.font.Font(self, self.cget("font"))
                  for key, value in style.items():
          Severity: Minor
          Found in pytknvim/tk_util.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 debug_echo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def debug_echo(func):
              '''used on method to simply print the function name and
              parameters if self.debug_echo = True,
              the function will not execute'''
              @wraps(func)
          Severity: Minor
          Found in pytknvim/util.py - About 45 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 highlight_pattern has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def highlight_pattern(self, pattern, tag, start="1.0",
          Severity: Minor
          Found in pytknvim/tk_util.py - About 35 mins to fix

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

                def _tk_tag_region(self, tag, top, bot, left, right):
            Severity: Minor
            Found in pytknvim/tk_canvas.py - About 35 mins to fix

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

                  def _tk_tag_region(self, tag, top, bot, left, right):
              Severity: Minor
              Found in pytknvim/tarruda.py - About 35 mins to fix

                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

                  Severity
                  Category
                  Status
                  Source
                  Language