Showing 67 of 84 total issues
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, test, dst, tolerance, primary=False, params=None):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, host, workers, base_output_path,
Function comma_separated_ranges_to_list
has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring. Open
def comma_separated_ranges_to_list(text):
"""
Provides a list from comma separated ranges
:param text: string of comma separated range
- Read upRead up
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 __init__
has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring. Open
def __init__(self, mean_tolerance, stddev_tolerance, model=None):
self.mean_tolerance = mean_tolerance
self.stddev_tolerance = stddev_tolerance
if model:
with open(model, encoding="utf-8") as fd_model:
- Read upRead up
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_output
has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring. Open
def check_output(*args, **kwargs):
"""
Execute command while masking stdin and providing better errors.
:param args: args to be passed to subprocess.check_output
- Read upRead up
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
Refactor this function to reduce its Cognitive Complexity from 35 to the 15 allowed. Open
def iter_results(path, skip_incorrect=False):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed. Open
def get_session(self, timeout=60, hop=None):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Method "record_result" has 10 parameters, which is greater than the 7 authorized. Open
def record_result(self, test_name, src, dst, primary=False, grouped=False,
difference=None, tolerance=None, params=None,
last=False):
- Read upRead up
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
def do_something(param1, param2, param3, param4, param5): ...
Compliant Solution
def do_something(param1, param2, param3, param4): ...
FIXME found Open
# FIXME: Return this when https://github.com/distributed
- Exclude checks
Take the required action to fix the issue indicated by this "FIXME" comment. Open
# FIXME: Workaround missing perl paths
- Read upRead up
- Exclude checks
FIXME
tags are commonly used to mark places where a bug is suspected, but which the developer wants to deal with later.
Sometimes the developer will not have the time or will simply forget to get back to that tag.
This rule is meant to track those tags and to ensure that they do not go unnoticed.
Noncompliant Code Example
def divide(numerator, denominator): return numerator / denominator # FIXME denominator value might be 0
See
- MITRE, CWE-546 - Suspicious Comment
FIXME found Open
{#- FIXME: Bring unique back; probably using [] and append #}
- Exclude checks
Refactor this function to reduce its Cognitive Complexity from 40 to the 15 allowed. Open
def main():
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed. Open
def _recalculate(self):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 29 to the 15 allowed. Open
def process_result_json(src_path, dst_base):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Method "__init__" has 9 parameters, which is greater than the 7 authorized. Open
def __init__(self, host, name, distro, base_image, smp, mem,
default_passwords=None, extra_params=None):
- Read upRead up
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
def do_something(param1, param2, param3, param4, param5): ...
Compliant Solution
def do_something(param1, param2, param3, param4): ...
Merge this if statement with the enclosing one. Open
if os.path.exists(split_arg[1]):
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if condition1: if condition2: # ...
Compliant Solution
if condition1 and condition2: # ...
Take the required action to fix the issue indicated by this "FIXME" comment. Open
# FIXME: Ugly IPv4-libvirt-bridge-only hack to use main host
- Read upRead up
- Exclude checks
FIXME
tags are commonly used to mark places where a bug is suspected, but which the developer wants to deal with later.
Sometimes the developer will not have the time or will simply forget to get back to that tag.
This rule is meant to track those tags and to ensure that they do not go unnoticed.
Noncompliant Code Example
def divide(numerator, denominator): return numerator / denominator # FIXME denominator value might be 0
See
- MITRE, CWE-546 - Suspicious Comment
FIXME found Open
# FIXME: Ugly IPv4-libvirt-bridge-only hack to use main host
- Exclude checks
FIXME found Open
{# FIXME: Bring unique back; probably using [] and append -#}
- Exclude checks
FIXME found Open
# FIXME: Workaround missing perl paths
- Exclude checks