avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

Function create_namespace has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def create_namespace(
        self,
        region="",
        bus="",
        n_type="pmem",
Severity: Minor
Found in avocado/utils/pmem.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 run_suite has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def run_suite(self, job, test_suite):
        summary = set()

        if not test_suite.enabled:
            job.interrupted_reason = f"Suite {test_suite.name} is disabled."
Severity: Minor
Found in avocado/plugins/runner_nrunner.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 get_buddy_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_buddy_info(chunk_sizes, nodes="all", zones="all"):
    """
    Get the fragment status of the host.

    It uses the same method to get the page size in buddyinfo. The expression
Severity: Minor
Found in avocado/utils/memory.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 set_freq_governor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def set_freq_governor(governor="random"):
    """
    To change the given cpu frequency governor.

    :param governor: frequency governor profile name whereas `random` is default
Severity: Minor
Found in avocado/utils/cpu.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 get_versions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def get_versions(self):
        """Return all available versions for the current parameters."""
        parser = VMImageHtmlParser(self.version_pattern)
        self._feed_html_parser(self.url_versions, parser)

Severity: Minor
Found in avocado/utils/vmimage.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 fail_on_dmesg has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def fail_on_dmesg(level=5):
    """Dmesg fail method decorator

    Returns a class decorator used to signal the test when DmesgError
    exception is raised.
Severity: Minor
Found in avocado/utils/dmesg.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 iso has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def iso(
    output_path,
    instance_id,
    username=None,
    password=None,
Severity: Minor
Found in avocado/utils/cloudinit.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

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

    def setUp(self):
        self.log.info("setup pre")
        self.log.warn("")
        self.log.info("setup post")
Severity: Major
Found in selftests/.data/test_statuses.py and 1 other location - About 1 hr to fix
selftests/.data/test_statuses.py on lines 172..175

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

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

Function _get_datadir has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_datadir(self, source):
        path_components = self._data_sources_mapping.get(source)
        if path_components is None:
            return

Severity: Minor
Found in avocado/core/test.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

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

    def test(self):
        self.log.info("test pre")
        self.log.warn("")
        self.log.info("test post")
Severity: Major
Found in selftests/.data/test_statuses.py and 1 other location - About 1 hr to fix
selftests/.data/test_statuses.py on lines 152..155

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

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

Function run_suite has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run_suite(self, job, test_suite):
        summary = set()

        if not test_suite.enabled:
            job.interrupted_reason = f"Suite {test_suite.name} is disabled."
Severity: Minor
Found in avocado/plugins/runner_nrunner.py - About 1 hr to fix

    Function __init__ has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self, config=None, test_suites=None):
            """Creates an instance of Job class.
    
            Note that `config` and `test_suites` are optional, if not passed you
            need to change this before running your tests. Otherwise nothing will
    Severity: Minor
    Found in avocado/core/job.py - About 1 hr to fix

      Function run_and_check has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def run_and_check(
      Severity: Major
      Found in selftests/functional/basic.py - About 1 hr to fix

        Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in avocado/utils/process.py - About 1 hr to fix

          Function get has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def get(
          Severity: Major
          Found in avocado/utils/vmimage.py - About 1 hr to fix

            Function get_tasks_from_test_task has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def get_tasks_from_test_task(
            Severity: Major
            Found in avocado/core/task/runtime.py - About 1 hr to fix

              Function from_runnable has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def from_runnable(
              Severity: Major
              Found in avocado/core/task/runtime.py - About 1 hr to fix

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

                    def pre_tests(self, job):
                        if not self.sysinfo_enabled:
                            return
                        self._init_sysinfo(job.logdir)
                        self.sysinfo.start()
                Severity: Major
                Found in avocado/plugins/sysinfo.py and 1 other location - About 1 hr to fix
                avocado/plugins/sysinfo.py on lines 193..197

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

                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

                Function fetch_asset has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def fetch_asset(
                Severity: Major
                Found in avocado/core/test.py - About 1 hr to fix

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

                      def post_tests(self, job):
                          if not self.sysinfo_enabled:
                              return
                          self._init_sysinfo(job.logdir)
                          self.sysinfo.end()
                  Severity: Major
                  Found in avocado/plugins/sysinfo.py and 1 other location - About 1 hr to fix
                  avocado/plugins/sysinfo.py on lines 187..191

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language