rgs1/zk_shell

View on GitHub
zk_shell/util.py

Summary

Maintainability
A
2 hrs
Test Coverage

Function find_outliers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def find_outliers(group, delta):
    """
    given a list of values, find those that are apart from the rest by
    `delta`. the indexes for the outliers is returned, if any.

Severity: Minor
Found in zk_shell/util.py - About 55 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 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

Avoid too many return statements within this function.
Open

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

    There are no issues that match your filters.

    Category
    Status