rgs1/zk_shell

View on GitHub

Showing 84 of 141 total issues

Function get has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self, ptotal=None):
        reqs = Queue()
        pending = 1
        total = 0
        path = self.path
Severity: Minor
Found in zk_shell/usage.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 do_tree has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def do_tree(self, path, max_depth, level, full_path, include_stat):
        """ tree's work horse """
        try:
            children = self.get_children(path)
        except (NoNodeError, NoAuthError):
Severity: Minor
Found in zk_shell/xclient.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 do_watch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def do_watch(self, params):
        """
\x1b[1mNAME\x1b[0m
        watch - Recursively watch for all changes under a path.

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

    def do_json_remove(self, params):
        """
\x1b[1mNAME\x1b[0m
        json_remove - remove occurrences of the given value from a list

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

    def zk_walk(self, root_path, branch_path):
        """
        skip ephemeral znodes since there's no point in copying those
        """
        full_path = os.path.join(root_path, branch_path) if branch_path else root_path
Severity: Minor
Found in zk_shell/copy_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 do_loop has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def do_loop(self, params):
        """
\x1b[1mNAME\x1b[0m
        loop - Runs commands in a loop

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

    def _complete_path(self, cmd_param_text, full_cmd, *_):
        """ completes paths """
        if full_cmd.endswith(" "):
            cmd_param, path = " ", " "
        else:
Severity: Minor
Found in zk_shell/shell.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 do_json_cat has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def do_json_cat(self, params):
        """
\x1b[1mNAME\x1b[0m
        json_cat - Pretty prints a znode's JSON

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

    def _cmd(self, endpoint, cmd):
        """ endpoint is (host, port) """
        cmdbuf = "%s\n" % (cmd)
        # some cmds have large outputs and ZK closes the connection as soon as it
        # finishes writing. so read in huge chunks.
Severity: Minor
Found in zk_shell/xclient.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 do_json_valid has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def do_json_valid(self, params):
        """
\x1b[1mNAME\x1b[0m
        json_valid - Checks znodes for valid JSON

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

    def diff(self, path_a, path_b):
        """ Performs a deep comparison of path_a/ and path_b/

            For each child, it yields (rv, child) where rv:
             -1 if doesn't exist in path_b (destination)
Severity: Minor
Found in zk_shell/xclient.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 do_child_matches has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def do_child_matches(self, params):
        """
\x1b[1mNAME\x1b[0m
        child_matches - Prints paths that have at least 1 child that matches <pattern>

Severity: Minor
Found in zk_shell/shell.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 do_chkzk has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def do_chkzk(self, params):
        """
\x1b[1mNAME\x1b[0m
        chkzk - Consistency check for a cluster

Severity: Minor
Found in zk_shell/shell.py - About 1 hr to fix

    Function children_of has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def children_of(self):
            if self.asynchronous:
                offs = 1 if self.path == "/" else len(self.path) + 1
                for path, stat in StatMap(self.client, self.path, recursive=True).get():
                    if stat.ephemeralOwner == 0:
    Severity: Minor
    Found in zk_shell/copy_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 do_edit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_edit(self, params):
            """
    \x1b[1mNAME\x1b[0m
            edit - Opens up an editor to modify and update a znode.
    
    
    Severity: Minor
    Found in zk_shell/shell.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 extract_acl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def extract_acl(cls, acl):
            """ parse an individual ACL (i.e.: world:anyone:cdrwa) """
            try:
                scheme, rest = acl.split(":", 1)
                credential = ":".join(rest.split(":")[0:-1])
    Severity: Minor
    Found in zk_shell/acl.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 do_json_get has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_json_get(self, params):
            """
    \x1b[1mNAME\x1b[0m
            json_get - Get key (or keys, if nested) from a JSON object serialized in the given path
    
    
    Severity: Minor
    Found in zk_shell/shell.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 children_of has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def children_of(self):
            root_path = self.path[0:-1] if self.path.endswith("/") else self.path
            for path, _, files in os.walk(root_path):
                path = path.replace(root_path, "")
                if path.startswith("/"):
    Severity: Minor
    Found in zk_shell/copy_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 do_json_set_many has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_json_set_many(self, params):
            """
    \x1b[1mNAME\x1b[0m
            json_set_many - like `json_set`, but for multiple key/value pairs
    
    
    Severity: Minor
    Found in zk_shell/shell.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 _watcher has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _watcher(self, watched_event):
            for path, stats in self._stats_by_path.items():
                if not watched_event.path.startswith(path):
                    continue
    
    
    Severity: Minor
    Found in zk_shell/watch_manager.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