ArturSpirin/test_junkie

View on GitHub
test_junkie/metrics.py

Summary

Maintainability
A
3 hrs
Test Coverage

File metrics.py has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import errno
import multiprocessing
import os
import sys
import threading
Severity: Minor
Found in test_junkie/metrics.py - About 4 hrs to fix

    Function update_metrics has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Wontfix

        def update_metrics(self, status, start_time, param=None, class_param=None, exception=None,
    Severity: Major
    Found in test_junkie/metrics.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Wontfix

                              if subcategory == 0:
                                  report[category]["exceptions"].append(entry)
                                  report["_totals_"]["exceptions"].append(entry)
                              else:
                                  report[category][subcategory]["exceptions"].append(entry)
      Severity: Major
      Found in test_junkie/metrics.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for param, param_data in class_param_data.items():
                                    if param != "None":
                                        print("\t    |__ parameter: {parameter}".format(parameter=param))
                                    for index in range(param_data["retry"]):
                                        trace = param_data["tracebacks"][index]
        Severity: Major
        Found in test_junkie/metrics.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if class_param != "None":
                                      print("\t  |__ class parameter: {class_parameter}".format(class_parameter=class_param))
                                  for param, param_data in class_param_data.items():
          Severity: Major
          Found in test_junkie/metrics.py - About 45 mins to fix

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

                def get_report_by_tags(self):
            Severity: Critical
            Found in test_junkie/metrics.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 _update_report(report, metrics, category, subcategory=0):
            Severity: Critical
            Found in test_junkie/metrics.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 60 to the 15 allowed.
            Open

                def present_console_output(aggregator):
            Severity: Critical
            Found in test_junkie/metrics.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 remove or fill this block of code.
            Open

                            pass
            Severity: Major
            Found in test_junkie/metrics.py by sonar-python

            Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.

            Noncompliant Code Example

            for i in range(3):
                pass
            

            Exceptions

            When a block contains a comment, this block is not considered to be empty.

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

                            for entry in data["performance"]:
                                if subcategory == 0:
                                    report[category]["performance"].append(entry)
                                    report["_totals_"]["performance"].append(entry)
                                else:
            Severity: Major
            Found in test_junkie/metrics.py and 1 other location - About 6 hrs to fix
            test_junkie/metrics.py on lines 259..265

            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 107.

            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

                                if entry is not None:
                                    if subcategory == 0:
                                        report[category]["exceptions"].append(entry)
                                        report["_totals_"]["exceptions"].append(entry)
                                    else:
            Severity: Major
            Found in test_junkie/metrics.py and 1 other location - About 6 hrs to fix
            test_junkie/metrics.py on lines 251..257

            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 107.

            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

                        self.__stats[string_class_param][string_param][decorator]["exceptions"]\
                            .append(Limiter.parse_exception_object(exception))
            Severity: Major
            Found in test_junkie/metrics.py and 1 other location - About 1 hr to fix
            test_junkie/metrics.py on lines 115..116

            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 41.

            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

                        self.__stats[string_class_param][string_param][decorator]["tracebacks"]\
                            .append(Limiter.parse_traceback(formatted_traceback))
            Severity: Major
            Found in test_junkie/metrics.py and 1 other location - About 1 hr to fix
            test_junkie/metrics.py on lines 113..114

            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 41.

            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.
            Open

                        self.__stats[string_class_param][string_param]["exceptions"]\
                            .append(Limiter.parse_exception_object(exception))
            Severity: Minor
            Found in test_junkie/metrics.py and 1 other location - About 45 mins to fix
            test_junkie/metrics.py on lines 126..127

            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.
            Open

                        self.__stats[string_class_param][string_param]["tracebacks"]\
                            .append(Limiter.parse_traceback(formatted_traceback))
            Severity: Minor
            Found in test_junkie/metrics.py and 1 other location - About 45 mins to fix
            test_junkie/metrics.py on lines 124..125

            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.
            Open

                    print(". Test Junkie {} (Python{}) {} .".format(
                        pkg_resources.require("test-junkie")[0].version, sys.version_info[0], DocumentationLinks.DOMAIN)
            Severity: Minor
            Found in test_junkie/metrics.py and 1 other location - About 45 mins to fix
            test_junkie/cli/cli.py on lines 198..201

            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

                            for entry in metric_data["performance"]:
                                report[metric]["performance"].append(entry)
            Severity: Minor
            Found in test_junkie/metrics.py and 1 other location - About 35 mins to fix
            test_junkie/metrics.py on lines 215..216

            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 33.

            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

                            for retry in metric_data["retries"]:
                                report[metric]["retries"].append(retry)
            Severity: Minor
            Found in test_junkie/metrics.py and 1 other location - About 35 mins to fix
            test_junkie/metrics.py on lines 210..211

            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 33.

            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