avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

Function save has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def save(self, ipaddr, netmask):
        """Save current interface IP Address to the system configuration file.

        If the ipaddr is valid (currently being used by the interface)
        this will try to save the current settings into /etc/. This
Severity: Minor
Found in avocado/utils/network/interfaces.py - About 6 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 varianter_yaml_to_mux.py has 418 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.
#

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

        def test_get_idle_state_on(self):
            retval = {0: {0: True}}
            with unittest.mock.patch("avocado.utils.cpu.online_list", return_value=[0]):
                with unittest.mock.patch(
                    "glob.glob",
    Severity: Major
    Found in selftests/unit/utils/cpu.py and 1 other location - About 5 hrs to fix
    selftests/unit/utils/cpu.py on lines 197..206

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

    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_get_idle_state_off(self):
            retval = {0: {0: False}}
            with unittest.mock.patch("avocado.utils.cpu.online_list", return_value=[0]):
                with unittest.mock.patch(
                    "glob.glob",
    Severity: Major
    Found in selftests/unit/utils/cpu.py and 1 other location - About 5 hrs to fix
    selftests/unit/utils/cpu.py on lines 208..217

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

    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 messages.py has 411 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/core/messages.py - About 5 hrs to fix

      Function filter_tags_on_runnables has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

      def filter_tags_on_runnables(
          resolutions, filter_by_tags, include_empty=False, include_empty_key=False
      ):
          """
          Filters out runnables that do not match the tags criteria given
      Severity: Minor
      Found in avocado/core/tags.py - About 5 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

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

              with patch("builtins.open", mock_open(read_data=NOT_TEST_CLASS_SOURCE)):
                  with patch.object(assets.ast, "parse"):
                      with patch.object(assets.FetchAssetHandler, "visit"):
                          with patch.object(assets.FetchAssetHandler, "generic_visit"):
                              handler = assets.FetchAssetHandler("fake_file.py", {})
      Severity: Major
      Found in selftests/unit/plugin/assets.py and 2 other locations - About 5 hrs to fix
      selftests/unit/plugin/assets.py on lines 154..160
      selftests/unit/plugin/assets.py on lines 233..239

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

      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 3 locations. Consider refactoring.
      Open

              with patch("builtins.open", mock_open(read_data=NOT_TEST_CLASS_SOURCE)):
                  with patch.object(assets.ast, "parse"):
                      with patch.object(assets.FetchAssetHandler, "visit"):
                          with patch.object(assets.FetchAssetHandler, "generic_visit"):
                              handler = assets.FetchAssetHandler("fake_file.py", {})
      Severity: Major
      Found in selftests/unit/plugin/assets.py and 2 other locations - About 5 hrs to fix
      selftests/unit/plugin/assets.py on lines 154..160
      selftests/unit/plugin/assets.py on lines 189..195

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

      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 3 locations. Consider refactoring.
      Open

              with patch("builtins.open", mock_open(read_data=NOT_TEST_CLASS_SOURCE)):
                  with patch.object(assets.ast, "parse"):
                      with patch.object(assets.FetchAssetHandler, "visit"):
                          with patch.object(assets.FetchAssetHandler, "generic_visit"):
                              handler = assets.FetchAssetHandler("fake_file.py", {})
      Severity: Major
      Found in selftests/unit/plugin/assets.py and 2 other locations - About 5 hrs to fix
      selftests/unit/plugin/assets.py on lines 189..195
      selftests/unit/plugin/assets.py on lines 233..239

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

      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 iso9660.py has 394 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/iso9660.py - About 5 hrs to fix

        Function _examine_class has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        def _examine_class(
            target_module, target_class, determine_match, path, class_name, match
        ):
            """
            Examine a class from a given path
        Severity: Minor
        Found in avocado/core/safeloader/core.py - About 5 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 distro.py has 389 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/distro.py - About 5 hrs to fix

          Function merge has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              def merge(self, other):
                  """
                  Merges `other` node into this one without checking the name of the
                  other node. New values are appended, existing values overwritten
                  and unaffected ones are kept. Then all other node children are

          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

          Severity: Major
          Found in selftests/jobs/sleepjob_json_varianter.py and 1 other location - About 5 hrs to fix
          selftests/jobs/passjob_cit_varianter.py on lines 0..21

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

          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

          Severity: Major
          Found in selftests/jobs/passjob_cit_varianter.py and 1 other location - About 5 hrs to fix
          selftests/jobs/sleepjob_json_varianter.py on lines 0..21

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

          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 diff.py has 377 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/diff.py - About 5 hrs to fix

            File disk.py has 376 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/disk.py - About 5 hrs to fix

              File output_check.py has 374 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import json
              import os
              import unittest
              
              from avocado.core import exit_codes
              Severity: Minor
              Found in selftests/functional/output_check.py - About 5 hrs to fix

                File core.py has 368 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import ast
                import collections
                import sys
                from importlib.machinery import PathFinder
                
                
                Severity: Minor
                Found in avocado/core/safeloader/core.py - About 4 hrs to fix

                  Function factory has 120 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    var factory = function( $, DataTable ) {
                      "use strict";
                  
                  
                      /* Set the defaults for DataTables initialisation */
                    Severity
                    Category
                    Status
                    Source
                    Language