avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

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

    def test_filtering_zone(self, buddy_mocked):
        chunk_size = "0"
        result = memory.get_buddy_info(chunk_size, zones="DMA32")
        self.assertEqual(result[chunk_size], 987)
        self.assertTrue(buddy_mocked.called)
Severity: Major
Found in selftests/unit/utils/memory.py and 1 other location - About 2 hrs to fix
selftests/unit/utils/memory.py on lines 90..94

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

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

    def _no_test_in_process_table(self):
        """
        Make sure the test will be really gone from the
        process table.
        """
Severity: Minor
Found in selftests/functional/interrupt.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

Function run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self, config):
        for plugin_dispatcher, config_needed, job_needed in itertools.chain(
            dispatcher.get_dispatchers("avocado.core.dispatcher"),
            dispatcher.get_dispatchers("avocado.core.resolver"),
        ):
Severity: Minor
Found in avocado/plugins/plugins.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

Function run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self, config):
        tree = config.get("variants.tree")
        summary = config.get("variants.summary")
        variants = config.get("variants.variants")
        contents = config.get("variants.contents")
Severity: Minor
Found in avocado/plugins/variants.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

Function recursive_compare_dict has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def recursive_compare_dict(dict1, dict2, level="DictKey", diff_btw_dict=None):
    """
    Difference between two dictionaries are returned
    Dict values can be a dictionary, list and value

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

Function get_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def get_data(self, filename, source=None, must_exist=True):
        """
        Retrieves the path to a given data file.

        This implementation looks for data file in one of the sources
Severity: Minor
Found in avocado/core/test.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

File job_timeout.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import glob
import os
import tempfile
import unittest
import xml.dom.minidom
Severity: Minor
Found in selftests/functional/job_timeout.py - About 2 hrs to fix

    File partition.py has 259 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/utils/partition.py - About 2 hrs to fix

      File resolver.py has 258 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import os
      import stat
      import unittest.mock
      
      from avocado.core import resolver
      Severity: Minor
      Found in selftests/unit/resolver.py - About 2 hrs to fix

        File app.py has 257 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import argparse
        import inspect
        import json
        import os
        import re
        Severity: Minor
        Found in avocado/core/nrunner/app.py - About 2 hrs to fix

          DocstringDirectives has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class DocstringDirectives(unittest.TestCase):
          
              VALID_DIRECTIVES = [
                  ":avocado: foo",
                  " :avocado: foo",
          Severity: Minor
          Found in selftests/unit/safeloader_docstring.py - About 2 hrs to fix

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

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

              File result_mail.py has 256 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import json
              import logging
              import os
              import smtplib
              import time
              Severity: Minor
              Found in optional_plugins/mail/avocado_result_mail/result_mail.py - About 2 hrs to fix

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

                    def initialize(self, config):
                        subcommand = config.get("subcommand")
                        data = None
                
                        # Merge the multiplex

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

                    def _get_env(self, runnable):
                        clear_env = runnable.config.get("runner.exectest.clear_env", None)
                        if clear_env not in ["all", "system", None]:
                            raise ValueError(
                                f"The `runner.exectest.clear_env` value {clear_env} is not supported."
                Severity: Minor
                Found in avocado/plugins/runners/exec_test.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

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

                    def get_possible_values(self, row, parameter):
                        """
                        Compute all possible values for the given parameter.
                
                        These values are based on constraints and already picked values
                Severity: Minor
                Found in optional_plugins/varianter_cit/avocado_varianter_cit/Solver.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

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

                    def run(self, runnable):
                        # pylint: disable=W0201
                        self.runnable = runnable
                        try:
                            yield messages.StartedMessage.get()
                Severity: Minor
                Found in avocado/plugins/runners/python_unittest.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

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

                def get_ns_status(controller_name, ns_id):
                    """
                    Returns the status of namespaces on the specified controller
                
                    :param controller_name: name of the controller like nvme0
                Severity: Minor
                Found in avocado/utils/nvme.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

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

                def create_diff_report(change_diffs):
                    """
                    Pretty prints the output of the `change_diffs` variable.
                
                    :param change_diffs: detected differences as groups of lines with filepath keys and a tuple of
                Severity: Minor
                Found in avocado/utils/diff_validator.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

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

                def systemd_result_parser(command):
                    """
                    Parse results from systemd style commands.
                
                    command status: return true if service is running.
                Severity: Minor
                Found in avocado/utils/service.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

                Severity
                Category
                Status
                Source
                Language