avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

Function process_node has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def process_node(node):
        """
        Generate this node's tree-view
        :return: list of lines
        """
Severity: Minor
Found in avocado/core/tree.py - About 2 hrs 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

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

        with open(
            os.path.join(self.job.logdir, "reversed_id"), encoding="utf-8"
        ) as reverse_id_file:
            self.assertEqual(self.job.unique_id[::-1], reverse_id_file.read())
Severity: Major
Found in selftests/unit/job.py and 1 other location - About 2 hrs to fix
selftests/unit/job.py on lines 228..231

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

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

def _must_key_val_matches(must_key_vals, test_tags, include_empty_key):
    """
    Checks if the required key:vals are fulfilled by the test_tags

    :rtype: bool
Severity: Minor
Found in avocado/core/tags.py - About 2 hrs 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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

        with mock.patch.object(
            LXCSpawner, "run_container_cmd", return_value=(0, "", "")
        ):
            with mock.patch.object(
                LXCSpawner, "run_container_cmd_async", return_value=(0, "", "")
Severity: Major
Found in selftests/functional/plugin/spawners/lxc.py and 2 other locations - About 2 hrs to fix
selftests/functional/plugin/spawners/lxc.py on lines 60..66
selftests/functional/plugin/spawners/lxc.py on lines 80..86

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

        with mock.patch.object(
            LXCSpawner, "run_container_cmd", return_value=(0, "", "")
        ):
            with mock.patch.object(
                LXCSpawner, "run_container_cmd_async", return_value=(0, "", "")
Severity: Major
Found in selftests/functional/plugin/spawners/lxc.py and 2 other locations - About 2 hrs to fix
selftests/functional/plugin/spawners/lxc.py on lines 40..46
selftests/functional/plugin/spawners/lxc.py on lines 80..86

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

        with mock.patch.object(
            LXCSpawner, "run_container_cmd", return_value=(0, "", "")
        ):
            with mock.patch.object(
                LXCSpawner, "run_container_cmd_async", return_value=(0, "", "")
Severity: Major
Found in selftests/functional/plugin/spawners/lxc.py and 2 other locations - About 2 hrs to fix
selftests/functional/plugin/spawners/lxc.py on lines 40..46
selftests/functional/plugin/spawners/lxc.py on lines 60..66

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

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

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

        with open(
            os.path.join(self.job.logdir, "reversed_id"), encoding="utf-8"
        ) as reverse_id_file:
            self.assertEqual(self.job.unique_id[::-1], reverse_id_file.read())
Severity: Major
Found in selftests/unit/job.py and 1 other location - About 2 hrs to fix
selftests/unit/job.py on lines 194..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 51.

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

File sysinfo.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# 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/plugins/sysinfo.py - About 2 hrs to fix

    File list.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import json
    import os
    import signal
    import stat
    import subprocess
    Severity: Minor
    Found in selftests/functional/list.py - About 2 hrs to fix

      File yum.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import configparser
      import logging
      import os
      import re
      import shutil
      Severity: Minor
      Found in avocado/utils/software_manager/backends/yum.py - About 2 hrs to fix

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

            def setUp(self):
                """Mock SoftwareManager"""
        
                self.sm_patcher = patch(
                    "avocado.plugins.runners.package.SoftwareManager", autospec=True
        Severity: Major
        Found in selftests/unit/runner_package.py and 1 other location - About 2 hrs to fix
        selftests/unit/runner_asset.py on lines 43..48

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

        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

            def setUp(self):
                """Mock SoftwareManager"""
        
                self.asset_patcher = patch("avocado.plugins.runners.asset.Asset", autospec=True)
                self.mock_asset = self.asset_patcher.start()
        Severity: Major
        Found in selftests/unit/runner_asset.py and 1 other location - About 2 hrs to fix
        selftests/unit/runner_package.py on lines 51..58

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

        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 __init__ has 16 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in avocado/core/settings.py - About 2 hrs to fix

          Function register_option has 16 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def register_option(
          Severity: Major
          Found in avocado/core/settings.py - About 2 hrs to fix

            Function file_has_content has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def file_has_content(file_path, content, regex):
                    """Check if a file has `content`."""
                    if os.path.isfile(file_path):
                        with open(file_path, "r", encoding="utf-8") as f:
                            lines = f.readlines()
            Severity: Minor
            Found in selftests/check.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 to_str has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_str(self, summary, variants, **kwargs):
                    """
                    Return human readable representation
            
                    The summary/variants accepts verbosity where 0 means silent and

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

            def _mapping_to_tree_loader(loader, node, looks_like_node=False):
                """Maps yaml mapping tag to TreeNode structure"""
                _value = []
                for key_node, value_node in node.value:
                    # Allow only strings as dict keys

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

                def pre(self, job):
                    for suite in job.test_suites:
                        dependency_file_path = suite.config.get("job.run.dependency")
                        if dependency_file_path:
                            try:
            Severity: Minor
            Found in avocado/plugins/dependency.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_nslist_with_pci has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_nslist_with_pci(pci_address):
                """
                Fetches and returns list of namespaces for specified pci_address
            
                :param pci_address: pci_address of any nvme adapter
            Severity: Minor
            Found in avocado/utils/nvme.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 provides has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def provides(self, name):
                    """
                    Return a list of packages that provide [name of package/file].
            
                    :param name: File name.
            Severity: Minor
            Found in avocado/utils/software_manager/backends/apt.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

            Severity
            Category
            Status
            Source
            Language