avocado-framework/avocado

View on GitHub
avocado/core/suite.py

Summary

Maintainability
C
7 hrs
Test Coverage
A
92%

File suite.py has 306 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
Severity: Minor
Found in avocado/core/suite.py - About 3 hrs to fix

    TestSuite has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TestSuite:
        def __init__(self, name, config=None, tests=None, job_config=None,
                     resolutions=None):
            self.name = name
            self.tests = tests
    Severity: Minor
    Found in avocado/core/suite.py - About 2 hrs to fix

      Function resolutions_to_runnables has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def resolutions_to_runnables(resolutions, config):
          """
          Transforms resolver resolutions into runnables suitable for a suite
      
          A resolver resolution
      Severity: Minor
      Found in avocado/core/suite.py - About 1 hr to fix

      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 8 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def __init__(self, name, config=None, tests=None, job_config=None,
                       resolutions=None):
              self.name = name
              self.tests = tests
              self.resolutions = resolutions
      Severity: Minor
      Found in avocado/core/suite.py - About 45 mins to fix

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

          def __init__(self, name, config=None, tests=None, job_config=None,
      Severity: Minor
      Found in avocado/core/suite.py - About 35 mins to fix

        Function _from_config_with_loader has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _from_config_with_loader(cls, config, name=None):
                references = config.get('run.references')
                ignore_missing = config.get('run.ignore_missing_references')
                verbose = config.get('core.verbose')
                subcommand = config.get('subcommand')
        Severity: Minor
        Found in avocado/core/suite.py - About 35 mins to fix

        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 _convert_to_dry_run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _convert_to_dry_run(self):
                if self.config.get('run.test_runner') == 'nrunner':
                    for runnable in self.tests:
                        runnable.kind = 'dry-run'
                else:
        Severity: Minor
        Found in avocado/core/suite.py - About 25 mins to fix

        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 variants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def variants(self):
                if self._variants is None:
                    variants = Varianter()
                    if not variants.is_parsed():
                        try:
        Severity: Minor
        Found in avocado/core/suite.py - About 25 mins to fix

        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 _get_tags_stats_from_nrunner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_tags_stats_from_nrunner(self):
                stats = {}
                for runnable in self.tests:
                    if runnable is None:
                        continue
        Severity: Minor
        Found in avocado/core/suite.py - About 25 mins to fix

        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 from_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def from_config(cls, config, name=None, job_config=None):
                """Helper method to create a TestSuite from config dicts.
        
                This is different from the TestSuite() initialization because here we
                are assuming that you need some help to build the test suite. Avocado
        Severity: Minor
        Found in avocado/core/suite.py - About 25 mins to fix

        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

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

            @property
            def stats(self):
                """Return a statistics dict with the current tests."""
                runner_name = self.config.get('run.test_runner') or 'runner'
                if runner_name == 'runner':
        Severity: Major
        Found in avocado/core/suite.py and 1 other location - About 3 hrs to fix
        avocado/core/suite.py on lines 296..304

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

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

            @property
            def tags_stats(self):
                """Return a statistics dict with the current tests tags."""
                runner_name = self.config.get('run.test_runner') or 'runner'
                if runner_name == 'runner':
        Severity: Major
        Found in avocado/core/suite.py and 1 other location - About 3 hrs to fix
        avocado/core/suite.py on lines 275..283

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

        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

            @property
            def references(self):
                if self._references is None:
                    self._references = self.config.get('run.references')
                return self._references
        Severity: Major
        Found in avocado/core/suite.py and 1 other location - About 1 hr to fix
        avocado/core/job.py on lines 472..476

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

        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