rgs1/zk_shell

View on GitHub

Showing 84 of 141 total issues

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

    def do_get(self, params):
        """
\x1b[1mNAME\x1b[0m
        get - Gets the znode's value

Severity: Minor
Found in zk_shell/shell.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 pretty_bytes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def pretty_bytes(num):
    """ pretty print the given number of bytes """
    for unit in ['', 'KB', 'MB', 'GB']:
        if num < 1024.0:
            if unit == '':
Severity: Minor
Found in zk_shell/util.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 do_json_set has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def do_json_set(self, params):
        """
\x1b[1mNAME\x1b[0m
        json_set - Sets the value for the given (possibly nested) key on a JSON object serialized in the given path

Severity: Minor
Found in zk_shell/shell.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 _init_zk_client has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _init_zk_client(self, hosts_list):
        """
        Initialize the zookeeper client (based on the provided list of hosts.

        In the basic case, hostsp is a list of hosts like:
Severity: Minor
Found in zk_shell/shell.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 valid_ipv4 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def valid_ipv4(ip):
    """ check if ip is a valid ipv4 """
    match =  _valid_ipv4.match(ip)
    if match is None:
        return False
Severity: Minor
Found in zk_shell/util.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def add(self, path, debug, children):
        """
        Set a watch for path and (maybe) its children depending on the value
        of children:

Severity: Minor
Found in zk_shell/watch_manager.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 get_acls_recursive has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_acls_recursive(self, path, depth, include_ephemerals):
        """A recursive generator wrapper for get_acls

        :param path: path from which to start
        :param depth: depth of the recursion (-1 no recursion, 0 means no limit)
Severity: Minor
Found in zk_shell/xclient.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 grep has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def grep(self, path, content, flags, show_matches):
        for path, matches in self._zk.grep(path, content, flags):
            if show_matches:
                self.show_output("%s:", path)
                for match in matches:
Severity: Minor
Found in zk_shell/shell.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 check_path_absent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def check_path_absent(func):
    """
    check path doesn't exist (unless we are in a txn or it's sequential)

    note: when creating sequential znodes, a trailing slash means no prefix, i.e.:
Severity: Minor
Found in zk_shell/shell.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

Avoid too many return statements within this function.
Open

        return json.loads(value)
Severity: Major
Found in zk_shell/keys.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return True
    Severity: Major
    Found in zk_shell/util.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return ValueError('Unknown type')
      Severity: Major
      Found in zk_shell/keys.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return False
        Severity: Major
        Found in zk_shell/keys.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return
          Severity: Major
          Found in zk_shell/shell.py - About 30 mins to fix

            Function safe_list_set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def safe_list_set(plist, idx, fill_with, value):
                """
                Sets:
            
                ```
            Severity: Minor
            Found in zk_shell/keys.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

            Function do_set_acls has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def do_set_acls(self, params):
                    """
            \x1b[1mNAME\x1b[0m
                    set_acls - Sets ACLs for a given path
            
            
            Severity: Minor
            Found in zk_shell/shell.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

            Function sessions_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def sessions_info(self, hosts):
                    """Returns ClientInfo per session.
            
                    :param hosts: comma separated lists of members of the ZK ensemble.
                    :returns: A dictionary of (session_id, ClientInfo).
            Severity: Minor
            Found in zk_shell/xclient.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

            Function do_diff has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def do_diff(self, params):
                    """
            \x1b[1mNAME\x1b[0m
                    diff - Display the differences between two paths
            
            
            Severity: Minor
            Found in zk_shell/shell.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

            Function check_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def check_path(self):
                    try:
                        retval = True if self.client.exists(self.path) else False
                    except NoAuthError:
                        raise AuthError("read", self.path)
            Severity: Minor
            Found in zk_shell/copy_util.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

            Function _watch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _watch(self, path, current_level, max_level):
                    """
                    we need to catch ZNONODE because children might be removed whilst we
                    are iterating (specially ephemeral znodes)
                    """
            Severity: Minor
            Found in zk_shell/watch_manager.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

            Severity
            Category
            Status
            Source
            Language