Showing 15 of 15 total issues
File test_ansible_role_support_integration.py
has 552 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
import pytest
from goodplay_helpers import smart_create
File test_ansible_runner_integration.py
has 477 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
import logging
import pytest
File test_collection.py
has 467 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from goodplay_helpers import smart_create
File test_docker_support_integration.py
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
import pytest
from goodplay_helpers import skip_if_no_docker, smart_create
Cyclomatic complexity is too high in function config_paths_for_playbook_path. (9) Open
def config_paths_for_playbook_path(playbook_path): # noqa: R701
base_path = playbook_path.dirpath()
# get relative config names sorted descending by len
config_names = [path.relto(base_path) for path in base_path.listdir(is_docker_compose_file)]
- Read upRead up
- Exclude checks
Cyclomatic Complexity
Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.
Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:
Construct | Effect on CC | Reasoning |
---|---|---|
if | +1 | An if statement is a single decision. |
elif | +1 | The elif statement adds another decision. |
else | +0 | The else statement does not cause a new decision. The decision is at the if. |
for | +1 | There is a decision at the start of the loop. |
while | +1 | There is a decision at the while statement. |
except | +1 | Each except branch adds a new conditional path of execution. |
finally | +0 | The finally block is unconditionally executed. |
with | +1 | The with statement roughly corresponds to a try/except block (see PEP 343 for details). |
assert | +1 | The assert statement internally roughly equals a conditional statement. |
Comprehension | +1 | A list/set/dict comprehension of generator expression is equivalent to a for loop. |
Boolean Operator | +1 | Every boolean operator (and, or) adds a decision point. |
CallbackModule
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'goodplay'
Function config_paths_for_playbook_path
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def config_paths_for_playbook_path(playbook_path): # noqa: R701
base_path = playbook_path.dirpath()
# get relative config names sorted descending by len
config_names = [path.relto(base_path) for path in base_path.listdir(is_docker_compose_file)]
- 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 monkeypatch_play_context
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def monkeypatch_play_context():
original_set_task_and_variable_override = PlayContext.set_task_and_variable_override
def goodplay_set_task_and_variable_override(self, task, *args, **kwargs):
new_info = original_set_task_and_variable_override(self, task, *args, **kwargs)
- 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 smart_content_iter
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def smart_content_iter(smart_content, path_prefix):
rel_path = None
content = []
for line in smart_content.splitlines():
- 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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, ctx, fspath, parent=None, config=None, session=None):
Function smart_create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def smart_create(base_path, smart_content):
smart_content = textwrap.dedent(smart_content)
print(smart_content)
- 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 role_path
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def role_path(self):
for ancestor_path in self.playbook_path.parts(reverse=True)[1:]:
if ancestor_path.basename == 'tests':
role_path = ancestor_path.dirpath()
is_role_path = role_path.join('meta', 'main.yml').check(file=True)
- 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 __iter__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __iter__(self):
# override default Capture to read lines as long as streams are open,
# thus iteration is not being stopped by large pauses between lines
# being available
while self.streams_open():
- 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 final_test_task_outcome
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def final_test_task_outcome(self):
if self.per_host_outcomes:
outcomes = set(x['outcome'] for x in self.per_host_outcomes.values())
outcome_priority = ('failed', 'skipped', 'passed')
for outcome in outcome_priority:
- 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 wait_for_event
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def wait_for_event(self, event_name=None, **kwargs):
for event in self.receive_events():
if event['event_name'] == event_name \
and set(kwargs.items()).issubset(set(event['data'].items())):
return event
- 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"