avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

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

def parse_unified_diff_output(lines):
    """
    Parses the unified diff output of two files.

    :param lines: diff lines
Severity: Minor
Found in avocado/utils/diff_validator.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 map_method_with_return has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def map_method_with_return(self, method_name, *args, **kwargs):
        """
        The same as `map_method` but additionally reports the list of returned
        values and optionally deepcopies the passed arguments

Severity: Minor
Found in avocado/core/extension_manager.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_environment has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def get_environment(self):
        """Get node environment (values + preceding envs)"""
        if self._environment is None:
            self._environment = (
                self.parent.environment.copy() if self.parent else TreeEnvironment()
Severity: Minor
Found in avocado/core/tree.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 15 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, namespace, invoke_kwds=None):
        super().__init__(namespace, invoke_kwds)
        namespace = f"{self.settings_section()}.order"
        configured_order = settings.as_dict().get(namespace)
        ordered = []
Severity: Minor
Found in avocado/core/enabled_extension_manager.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

with Job(
    test_suites=[
        TestSuite.from_config(ORDERLY_CONFIG, name="orderly"),
        TestSuite.from_config(RANDOM_CONFIG, name="random"),
    ]
Severity: Major
Found in examples/jobs/multiple_suites_from_config.py and 1 other location - About 1 hr to fix
examples/jobs/multiple_spawners.py on lines 12..18

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

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

with Job(
    test_suites=[
        TestSuite.from_config(PROCESS_CONFIG, name="process"),
        TestSuite.from_config(PODMAN_CONFIG, name="podman"),
    ]
Severity: Major
Found in examples/jobs/multiple_spawners.py and 1 other location - About 1 hr to fix
examples/jobs/multiple_suites_from_config.py on lines 26..32

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

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 test_result_rate_none_succeeded(self):
        result = Result(UNIQUE_ID, LOGFILE)
        result.check_test({"status": "FAIL"})
        result.end_tests()
        self.assertEqual(result.rate, 0.0)
Severity: Major
Found in selftests/unit/result.py and 1 other location - About 1 hr to fix
selftests/unit/result.py on lines 18..22

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

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 test_result_rate_all_succeeded(self):
        result = Result(UNIQUE_ID, LOGFILE)
        result.check_test({"status": "PASS"})
        result.end_tests()
        self.assertEqual(result.rate, 100.0)
Severity: Major
Found in selftests/unit/result.py and 1 other location - About 1 hr to fix
selftests/unit/result.py on lines 52..56

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

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 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(
        self,
        methodName="test",
        name=None,
        params=None,
Severity: Minor
Found in avocado/core/test.py - About 1 hr to fix

    Function cover_combination has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def cover_combination(self, row, parameters):
            """
            Cover combination of specific parameters by one row from possible solution
    
            :param row: one row from solution

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

        def reserve_slot(self, runtime_task):
            """
            Reserve a free or custom remote host slot for the runtime task.
    
            :param runtime_task: runtime task to reserve the slot for
    Severity: Minor
    Found in optional_plugins/spawner_remote/avocado_spawner_remote/__init__.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 resolve has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def resolve(reference):  # pylint: disable=W0221
    
            if GO_BIN is None:
                return ReferenceResolution(
                    reference,
    Severity: Minor
    Found in optional_plugins/golang/avocado_golang/golang.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 uncover_combination has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def uncover_combination(self, row, parameters):
            """
            Uncover combination of specific parameters by one row from possible solution
    
            :param row: one row from solution

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

        def tests(self):
            mapping = {
                "SKIP": "warning",
                "ERROR": "danger",
                "FAIL": "danger",
    Severity: Minor
    Found in optional_plugins/html/avocado_result_html/__init__.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 is_valid_combination has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def is_valid_combination(self, row, parameters):
            """
            Is the specific parameters from solution row match the constraints.
    
            :param row: one row from solution

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

        def name_for_file_contains(self):
            """
            Get the distro if the :attr:`CHECK_FILE` is set and has content
            """
            if self.check_name_for_file_contains():
    Severity: Minor
    Found in avocado/utils/distro.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 analyze_unpickable_item has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def analyze_unpickable_item(path_prefix, obj):
        """
        Recursive method to obtain unpickable objects along with location
    
        :param path_prefix: Path to this object
    Severity: Minor
    Found in avocado/utils/stacktrace.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 mount has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def mount(self, mountpoint=None, fstype=None, args="", mnt_check=True):
            """
            Mount this partition to a mount point
    
            :param mountpoint: If you have not provided a mountpoint to partition
    Severity: Minor
    Found in avocado/utils/partition.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 strip_console_codes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def strip_console_codes(output, custom_codes=None):
        """
        Remove the Linux console escape and control sequences from the console
        output. Make the output readable and can be used for result check. Now
        only remove some basic console codes using during boot up.
    Severity: Minor
    Found in avocado/utils/astring.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_mountpoint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_mountpoint(self, filename=None):
            """
            Find the mount point of this partition object.
    
            :param filename: where to look for the mounted partitions information
    Severity: Minor
    Found in avocado/utils/partition.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