rgs1/zk_shell

View on GitHub

Showing 141 of 141 total issues

File shell.py has 2592 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""
A powerful & scriptable ZooKeeper shell
"""
Severity: Major
Found in zk_shell/shell.py - About 1 wk to fix

    Shell has 117 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Shell(XCmd):
        CONF_PATH = os.path.join(os.environ["HOME"], ".zk_shell")
        DEFAULT_CONF = Conf(
            ConfVar(
                "chkzk_stat_retries",
    Severity: Major
    Found in zk_shell/shell.py - About 2 days to fix

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

          @ensure_params(Optional("hosts"), Optional("match"))
          def do_dump(self, params):
              """
      \x1b[1mNAME\x1b[0m
              dump - Executes the dump four-letter command
      Severity: Major
      Found in zk_shell/shell.py and 2 other locations - About 1 day to fix
      zk_shell/shell.py on lines 1505..1539
      zk_shell/shell.py on lines 1541..1573

      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 149.

      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 3 locations. Consider refactoring.
      Open

          @ensure_params(Optional("hosts"), Optional("match"))
          def do_cons(self, params):
              """
      \x1b[1mNAME\x1b[0m
              cons - Executes the cons four-letter command
      Severity: Major
      Found in zk_shell/shell.py and 2 other locations - About 1 day to fix
      zk_shell/shell.py on lines 1505..1539
      zk_shell/shell.py on lines 1575..1613

      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 149.

      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 3 locations. Consider refactoring.
      Open

          @ensure_params(Optional("hosts"), Optional("match"))
          def do_mntr(self, params):
              """
      \x1b[1mNAME\x1b[0m
              mntr - Executes the mntr four-letter command
      Severity: Major
      Found in zk_shell/shell.py and 2 other locations - About 1 day to fix
      zk_shell/shell.py on lines 1541..1573
      zk_shell/shell.py on lines 1575..1613

      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 149.

      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

              if params.top == 0:
                  start, end = 0, len(results)
              elif params.top > 0:
                  start, end = 0, params.top if params.top < len(results) else len(results)
              else:
      Severity: Major
      Found in zk_shell/shell.py and 1 other location - About 1 day to fix
      zk_shell/shell.py on lines 2470..2476

      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 124.

      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

              if params.top == 0:
                  start, end = 0, len(results)
              elif params.top > 0:
                  start, end = 0, params.top if params.top < len(results) else len(results)
              else:
      Severity: Major
      Found in zk_shell/shell.py and 1 other location - About 1 day to fix
      zk_shell/shell.py on lines 900..906

      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 124.

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

          def __call__(self, params=None):
              """ parse params & loop forever """
              logging.basicConfig(level=logging.ERROR)
      
              if params is None:
      Severity: Minor
      Found in zk_shell/cli.py - About 6 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 xclient.py has 418 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      a decorated KazooClient with handy operations on a ZK datatree and its znodes
      """
      from contextlib import contextmanager
      import os
      Severity: Minor
      Found in zk_shell/xclient.py - About 6 hrs to fix

        File copy_util.py has 415 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """ helpers to move files/dirs to and from ZK and also among ZK clusters """
        
        from __future__ import print_function
        
        from base64 import b64decode, b64encode
        Severity: Minor
        Found in zk_shell/copy_util.py - About 5 hrs to fix

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

                      if params.confirm:
                          a = json.dumps(obj_src, sort_keys=True, indent=4)
                          b = json.dumps(obj_dst, sort_keys=True, indent=4)
                          diff = difflib.unified_diff(a.split("\n"), b.split("\n"))
                          self.show_output("\n".join(diff))
          Severity: Major
          Found in zk_shell/shell.py and 2 other locations - About 5 hrs to fix
          zk_shell/shell.py on lines 2133..2138
          zk_shell/shell.py on lines 2391..2396

          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 96.

          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 3 locations. Consider refactoring.
          Open

                      if params.confirm:
                          a = json.dumps(obj_src, sort_keys=True, indent=4)
                          b = json.dumps(obj_dst, sort_keys=True, indent=4)
                          diff = difflib.unified_diff(a.split("\n"), b.split("\n"))
                          self.show_output("\n".join(diff))
          Severity: Major
          Found in zk_shell/shell.py and 2 other locations - About 5 hrs to fix
          zk_shell/shell.py on lines 2133..2138
          zk_shell/shell.py on lines 2294..2299

          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 96.

          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 3 locations. Consider refactoring.
          Open

                      if params.confirm:
                          a = json.dumps(obj_src, sort_keys=True, indent=4)
                          b = json.dumps(obj_dst, sort_keys=True, indent=4)
                          diff = difflib.unified_diff(a.split("\n"), b.split("\n"))
                          self.show_output("\n".join(diff))
          Severity: Major
          Found in zk_shell/shell.py and 2 other locations - About 5 hrs to fix
          zk_shell/shell.py on lines 2294..2299
          zk_shell/shell.py on lines 2391..2396

          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 96.

          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

          XClient has 41 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class XClient():
              """ adds some extra methods to a wrapped KazooClient """
          
              class CmdFailed(Exception):
                  """ 4 letter cmd failed """
          Severity: Minor
          Found in zk_shell/xclient.py - About 5 hrs to fix

            Function connected has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

            def connected(func):
                """ check connected, fails otherwise """
                @wraps(func)
                def wrapper(*args, **kwargs):
                    self = args[0]
            Severity: Minor
            Found in zk_shell/shell.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

            Function do_chkzk has a Cognitive Complexity of 32 (exceeds 5 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 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

            Function set has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                def set(cls, obj, keys, value, fill_list_value=None):
                    """
                    sets the value for the given keys on obj. if any of the given
                    keys does not exist, create the intermediate containers.
                    """
            Severity: Minor
            Found in zk_shell/keys.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

            Function do_json_dupes_for_keys has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
            Open

                def do_json_dupes_for_keys(self, params):
                    """
            \x1b[1mNAME\x1b[0m
                    json_duples_for_keys - Gets the duplicate znodes for the given keys
            
            
            Severity: Minor
            Found in zk_shell/shell.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

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

                def get(self):
                    reqs = Queue()
                    child_pending = 1
                    data_pending = 0
                    path = self.path
            Severity: Minor
            Found in zk_shell/pathmap.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 check_path_exists_foreach has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            def check_path_exists_foreach(path_params, func):
                """ check that paths exist (unless we are in a transaction) """
                @wraps(func)
                def wrapper(*args):
                    self = args[0]
            Severity: Minor
            Found in zk_shell/shell.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

            Severity
            Category
            Status
            Source
            Language