ArturSpirin/test_junkie

View on GitHub
test_junkie/objects.py

Summary

Maintainability
A
3 hrs
Test Coverage

File objects.py has 392 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import copy
import inspect
import traceback
import sys
from test_junkie.decorators import DecoratorType
Severity: Minor
Found in test_junkie/objects.py - About 5 hrs to fix

    TestObject has 35 functions (exceeds 20 allowed). Consider refactoring.
    Invalid

    class TestObject(object):
    
        def __init__(self, test_definition, suite):
    
            self.__test_definition = test_definition
    Severity: Minor
    Found in test_junkie/objects.py - About 4 hrs to fix

      SuiteObject has 35 functions (exceeds 20 allowed). Consider refactoring.
      Wontfix

      class SuiteObject(object):
      
          def __init__(self, suite_definition):
      
              self.__suite_definition = suite_definition
      Severity: Minor
      Found in test_junkie/objects.py - About 4 hrs to fix

        Avoid too many return statements within this function.
        Open

                return can_skip
        Severity: Major
        Found in test_junkie/objects.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return False
          Severity: Major
          Found in test_junkie/objects.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

                                      return False
              Severity: Major
              Found in test_junkie/objects.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

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

                  Avoid too many return statements within this function.
                  Open

                          return False
                  Severity: Major
                  Found in test_junkie/objects.py - About 30 mins to fix

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

                        def run_after_group(self, suite):
                    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 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

                    Merge this if statement with the enclosing one.
                    Open

                                if isinstance(value, str) and len(value) > Limiter.TRACEBACK_LIMIT:
                    Severity: Major
                    Found in test_junkie/objects.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:
                        # ...
                    

                    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
                    

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Invalid

                            return self.metrics.get_metrics()[str(class_param)][str(param)]["status"]
                    Severity: Minor
                    Found in test_junkie/objects.py and 1 other location - About 45 mins to fix
                    test_junkie/objects.py on lines 479..479

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 35.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Invalid

                            return self.metrics.get_metrics()[str(class_param)][str(param)]["retry"]
                    Severity: Minor
                    Found in test_junkie/objects.py and 1 other location - About 45 mins to fix
                    test_junkie/objects.py on lines 473..473

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 35.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    There are no issues that match your filters.

                    Category
                    Status