atlassian/themis

View on GitHub
themis/util/remote.py

Summary

Maintainability
B
6 hrs
Test Coverage

Function get_ssh_keys has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def get_ssh_keys():
    keys = re.split(r'\s*,\s*', config.get_value(KEY_SSH_KEYS))
    for i in range(0, len(keys)):
        key = keys[i]
        if key[0] == '$':
Severity: Minor
Found in themis/util/remote.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 run_ssh has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def run_ssh(cmd, host, user=None, keys=None, via_hosts=[], cache_duration_secs=0):
    if not keys:
        keys = get_ssh_keys()

    user = '%s@' % user if user else ''
Severity: Minor
Found in themis/util/remote.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

Avoid deeply nested control flow statements.
Open

                    if marker_begin not in key_value:
                        key_value = ('%s\n' % marker_begin) + key_value
                    if marker_end not in key_value:
Severity: Major
Found in themis/util/remote.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if marker_end not in key_value:
                            key_value += ('\n%s' % marker_end)
                        key_value = key_value.replace('\n\n', '\n')
    Severity: Major
    Found in themis/util/remote.py - About 45 mins to fix

      Function run_ssh has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def run_ssh(cmd, host, user=None, keys=None, via_hosts=[], cache_duration_secs=0):
      Severity: Minor
      Found in themis/util/remote.py - About 45 mins to fix

        Error: invalid syntax (<unknown>, line 71)</unknown>
        Open

                except subprocess.CalledProcessError, e:
        Severity: Minor
        Found in themis/util/remote.py by radon

        We encountered an error attempting to analyze this line.

        TODO found
        Open

                    # TODO find a more elegant solution for this.
        Severity: Minor
        Found in themis/util/remote.py by fixme

        There are no issues that match your filters.

        Category
        Status