ArturSpirin/test_junkie

View on GitHub

Showing 113 of 184 total issues

Refactor this function to reduce its Cognitive Complexity from 45 to the 15 allowed.
Open

    def can_skip(self, settings):
Severity: Critical
Found in test_junkie/objects.py by sonar-python

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 20 to the 15 allowed.
Open

    def analyze(self, test_id, tracebacks, performance):
Severity: Critical
Found in test_junkie/reporter/analyzer.py by sonar-python

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 "update_metrics" has 9 parameters, which is greater than the 7 authorized.
Open

    def update_metrics(self, status, start_time, param=None, class_param=None, exception=None,
                       formatted_traceback=None, runtime=None, decorator=None):
Severity: Major
Found in test_junkie/metrics.py by sonar-python

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):
    ...

Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.
Open

    def get_meta(suite, parameter=None, suite_parameter=None):
Severity: Critical
Found in test_junkie/meta.py by sonar-python

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

Rename function "js" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

        def js():

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...

Either merge this branch with the identical one on line "463" or change one of the implementations.
Open

                return False
Severity: Major
Found in test_junkie/objects.py by sonar-python

Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

Noncompliant Code Example

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_thing()  # Noncompliant; duplicates first condition
else:
    do_the_rest()

b = 4 if a > 12 else 4

Compliant Solution

if (0 <= a < 10) or (20 <= a < 50):
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
else:
    do_the_rest()

b = 4

or

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_third_thing()
else:
    do_the_rest()

b = 8 if a > 12 else 4

Rename function "js" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

        def js():

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...

Refactor this function to reduce its Cognitive Complexity from 142 to the 15 allowed.
Open

    def __run_suite(self, suite):
Severity: Critical
Found in test_junkie/runner.py by sonar-python

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 28 to the 15 allowed.
Open

    def __positive_skip_condition(self, test):
Severity: Critical
Found in test_junkie/runner.py by sonar-python

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

Merge this if statement with the enclosing one.
Open

                        if suite.get_decorated_definition(DecoratorType.AFTER_TEST):
Severity: Major
Found in test_junkie/runner.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Rename function "js" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

        def js():

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...

Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed.
Open

    def update_context(self, suite, test, feature):
Severity: Critical
Found in test_junkie/cli/cli_audit.py by sonar-python

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

Either merge this branch with the identical one on line "426" or change one of the implementations.
Open

                    return  # fixes ticket: #27
Severity: Major
Found in test_junkie/runner.py by sonar-python

Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

Noncompliant Code Example

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_thing()  # Noncompliant; duplicates first condition
else:
    do_the_rest()

b = 4 if a > 12 else 4

Compliant Solution

if (0 <= a < 10) or (20 <= a < 50):
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
else:
    do_the_rest()

b = 4

or

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_third_thing()
else:
    do_the_rest()

b = 8 if a > 12 else 4

Refactor this function to reduce its Cognitive Complexity from 22 to the 15 allowed.
Open

    def __prioritize(suites=None, suite_object=None):
Severity: Critical
Found in test_junkie/runner.py by sonar-python

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 33 to the 15 allowed.
Open

    def __process_decorator(decorator_type, suite, test=None, parameter=None,  class_parameter=None):
Severity: Critical
Found in test_junkie/runner.py by sonar-python

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

Merge this if statement with the enclosing one.
Open

                        if record_test_failure:  # Test failed and failure was already recorded thus can't pass it
Severity: Major
Found in test_junkie/runner.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Merge this if statement with the enclosing one.
Open

                            if test_mapping["thread"].is_alive():
Severity: Major
Found in test_junkie/parallels.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Refactor this function to reduce its Cognitive Complexity from 105 to the 15 allowed.
Open

    def aggregate(self):
Severity: Critical
Found in test_junkie/cli/cli_audit.py by sonar-python

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

Merge this if statement with the enclosing one.
Open

                        if Analyzer.is_similar(traceback, key):

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Merge this if statement with the enclosing one.
Open

            if not self.__analysis["stable"]:

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...
Severity
Category
Status
Source
Language