knipknap/exscript

View on GitHub

Showing 153 of 245 total issues

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

def _require_authenticate(func):
    '''A decorator to add digest authorization checks to HTTP Request Handlers'''

    def wrapped(self):
        if not hasattr(self, 'authenticated'):
Severity: Minor
Found in Exscript/servers/httpd.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 value has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def value(self, context):
        if len(self.list_variables) == 0 and not self.thefrom:
            # If this is a "while" loop, iterate as long as the condition is
            # True.
            if self.during is not None:
Severity: Minor
Found in Exscript/interpreter/loop.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

Host has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class Host(object):

    """
    Represents a device on which to open a connection.
    """
Severity: Minor
Found in Exscript/host.py - About 2 hrs to fix

    Function __str__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def __str__(self):
            """
            Like :class:`to_string()`.
    
            :rtype:  str
    Severity: Minor
    Found in Exscript/util/url.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 clean_ip has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def clean_ip(ip):
        """
        Cleans the ip address up, useful for removing leading zeros, e.g.::
    
            1234:0:01:02:: -> 1234:0:1:2::
    Severity: Minor
    Found in Exscript/util/ipv6.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 get_terminal_size has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_terminal_size(default_rows=25, default_cols=80):
        """
        Returns the number of lines and columns of the current terminal.
        It attempts several strategies to determine the size and if all fail,
        it returns (80, 25).
    Severity: Minor
    Found in Exscript/util/tty.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

    Lexer has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Lexer(object):
    
        def __init__(self, parser_cls, *args, **kwargs):
            """
            The given args are passed to the parser_cls constructor.
    Severity: Minor
    Found in Exscript/parselib/lexer.py - About 2 hrs to fix

      Mail has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Mail(object):
      
          """
          Represents an email.
          """
      Severity: Minor
      Found in Exscript/util/mail.py - About 2 hrs to fix

        Function _decorate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def _decorate(flush=True, attempts=1, only_authenticate=False):
            """
            Wraps the given function such that conn.login() or conn.authenticate() is
            executed.
            Doing the real work for autologin and autoauthenticate to minimize code
        Severity: Minor
        Found in Exscript/util/decorator.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 normalize_ip has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def normalize_ip(ip):
            """
            Transform the address into a standard, fixed-length form, such as:
        
                1234:0:01:02:: -> 1234:0000:0001:0002:0000:0000:0000:0000
        Severity: Minor
        Found in Exscript/util/ipv6.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 get_hosts_from_csv has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_hosts_from_csv(filename,
                               default_protocol='telnet',
                               default_domain='',
                               encoding='utf-8'):
            """
        Severity: Minor
        Found in Exscript/util/file.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

        File workqueue.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #
        # Copyright (C) 2010-2017 Samuel Abels
        # The MIT License (MIT)
        #
        # Permission is hereby granted, free of charge, to any person obtaining
        Severity: Minor
        Found in Exscript/workqueue/workqueue.py - About 2 hrs to fix

          Function _domatch has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def _domatch(self, prompt, flush):
                  self._dbg(1, "Expecting a prompt")
                  self._dbg(2, "Expected pattern: " +
                            repr([repr(p.pattern) for p in prompt]))
                  search_window_size = 150
          Severity: Minor
          Found in Exscript/protocols/ssh2.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 interact has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def interact(self):
                  """Interaction function, emulates a very dumb telnet client."""
                  if sys.platform == "win32":
                      self.mt_interact()
                      return
          Severity: Minor
          Found in Exscript/protocols/telnetlib.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 emit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def emit(self, *args, **kwargs):
                  """
                  Emits the signal, passing the given arguments to the callbacks.
                  If one of the callbacks returns a value other than None, no further
                  callbacks are invoked and the return value of the callback is
          Severity: Minor
          Found in Exscript/util/event.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 _paramiko_auth_interactive has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def _paramiko_auth_interactive(self, username, password=None):
                  if password is None:
                      return
                  def handler(title, instructions, prompt_list):
                      if not prompt_list:
          Severity: Minor
          Found in Exscript/protocols/ssh2.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 a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self,
                           driver=None,
                           stdout=None,
                           stderr=None,
                           debug=0,
          Severity: Minor
          Found in Exscript/protocols/protocol.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 prompt has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          def prompt(key,
                     message,
                     default=None,
                     doverh=True,
                     strip=True,
          Severity: Minor
          Found in Exscript/util/interact.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 a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, lexer, parser, parent):
                  Token.__init__(self, 'Loop', lexer, parser, parent)
                  self.during = None
                  self.until = None
                  self.thefrom = None
          Severity: Minor
          Found in Exscript/interpreter/loop.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 _open_windows_shell has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def _open_windows_shell(self, channel, key_handlers, handle_window_size):
                  import threading
          
                  def writeall(sock):
                      while True:
          Severity: Minor
          Found in Exscript/protocols/protocol.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

          Severity
          Category
          Status
          Source
          Language