xcmd/xcmd.py

Summary

Maintainability
D
2 days
Test Coverage

File xcmd.py has 476 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" An augmented version of cmd """

from __future__ import print_function

from distutils.util import strtobool
Severity: Minor
Found in xcmd/xcmd.py - About 7 hrs to fix

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

    class XCmd(cmd.Cmd):
        """ extends cmd.Cmd """
    
        CONF_PATH = os.path.join(os.environ['HOME'], '.xcmd')
        DEFAULT_CONF = Conf(
    Severity: Minor
    Found in xcmd/xcmd.py - About 2 hrs to fix

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

          def do_conf(self, params):
              """
      \x1b[1mNAME\x1b[0m
              conf - Runtime configuration management
      
      
      Severity: Minor
      Found in xcmd/xcmd.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 ensure_params_with_parser has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def ensure_params_with_parser(parser, func):
          """ parse args with parser and run func """
          @wraps(func)
          def wrapper(*args):
              try:
      Severity: Minor
      Found in xcmd/xcmd.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 from_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_params(cls, params):
              """ generate an instance from a list of params """
              parser = cls()
              for param in params:
                  if isinstance(param, Required):
      Severity: Minor
      Found in xcmd/xcmd.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 default has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def default(self, line):
              try:
                  args = shlex.split(line)
              except ValueError:
                  if not line.startswith("#"):
      Severity: Minor
      Found in xcmd/xcmd.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 show_output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def show_output(self, fmt_str, *params, **kwargs):
              """ MAX_OUTPUT chars of the last output is available via $? """
              if PYTHON3:
                  fmt_str = str(fmt_str)
      
      
      Severity: Minor
      Found in xcmd/xcmd.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 do_pipe has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def do_pipe(self, params):
              """
              Pipe a series of commands
      
              pipe <cmd1> <cmd2> ... <cmdN>
      Severity: Minor
      Found in xcmd/xcmd.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

      There are no issues that match your filters.

      Category
      Status