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_relative_level0_name_from_level1(self):
        path = os.path.join(self.tmpdir.name, "l1", "l1lib1.py")
        self.assertEqual(
            find_avocado_tests(path)[0],
            {"BaseL1": [("test_l1", {}, []), ("test_l0", {}, [])]},
Severity: Major
Found in selftests/unit/safeloader_core.py and 1 other location - About 2 hrs to fix
selftests/unit/safeloader_core.py on lines 350..354

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

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_relative_level0_from_level1(self):
        path = os.path.join(self.tmpdir.name, "l1", "l1lib2.py")
        self.assertEqual(
            find_avocado_tests(path)[0],
            {"BaseL1": [("test_l1", {}, []), ("test_l0", {}, [])]},
Severity: Major
Found in selftests/unit/safeloader_core.py and 1 other location - About 2 hrs to fix
selftests/unit/safeloader_core.py on lines 343..347

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

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 requirements.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import glob
import os

from avocado import Test, skipUnless
from avocado.core import exit_codes
Severity: Minor
Found in selftests/functional/serial/requirements.py - About 2 hrs to fix

    Function perform_setup has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def perform_setup(self, packages, no_dependencies=False):
            """
            General RPM setup with automatic handling of dependencies based on
            install attempts.
    
    
    Severity: Minor
    Found in avocado/utils/software_manager/backends/rpm.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

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

    class IsoRead(BaseIso9660, unittest.TestCase):
        """
        IsoRead-based check
        """
    
    
    Severity: Major
    Found in selftests/unit/utils/iso9660.py and 1 other location - About 2 hrs to fix
    selftests/unit/utils/iso9660.py on lines 118..128

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

    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

    class IsoInfo(BaseIso9660, unittest.TestCase):
        """
        IsoInfo-based check
        """
    
    
    Severity: Major
    Found in selftests/unit/utils/iso9660.py and 1 other location - About 2 hrs to fix
    selftests/unit/utils/iso9660.py on lines 131..141

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

    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 skiptests.py has 281 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/skiptests.py - About 2 hrs to fix

      Function attach has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            var attach = function( container, buttons ) {
              var i, ien, node, button;
              var clickHandler = function ( e ) {
                e.preventDefault();
                if ( !$(e.currentTarget).hasClass('disabled') ) {

        PMem has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class PMem:
            """
            PMem class which provides function to perform ndctl and daxctl operations
        
            This class can be used only if ndctl binaries are provided before hand
        Severity: Minor
        Found in avocado/utils/pmem.py - About 2 hrs to fix

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

              def test_job_test_suite_not_created(self):
                  config = {"run.results_dir": self.tmpdir.name, "core.show": ["none"]}
                  self.job = job.Job(config)
                  self.job.setup()
                  self.assertIsNone(self.job.test_suite)
          Severity: Major
          Found in selftests/unit/job.py and 1 other location - About 2 hrs to fix
          selftests/unit/job.py on lines 71..75

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

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

              def test_s390x_get_version(self):
                  with unittest.mock.patch(
                      "avocado.utils.cpu.platform.machine", return_value="s390x"
                  ):
                      with unittest.mock.patch(
          Severity: Major
          Found in selftests/unit/utils/cpu.py and 5 other locations - About 2 hrs to fix
          selftests/unit/utils/cpu.py on lines 139..146
          selftests/unit/utils/cpu.py on lines 148..155
          selftests/unit/utils/cpu.py on lines 157..164
          selftests/unit/utils/cpu.py on lines 183..188
          selftests/unit/utils/cpu.py on lines 190..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 58.

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

              def test_power9_get_version(self):
                  with unittest.mock.patch(
                      "avocado.utils.cpu.platform.machine", return_value="powerpc"
                  ):
                      with unittest.mock.patch(
          Severity: Major
          Found in selftests/unit/utils/cpu.py and 5 other locations - About 2 hrs to fix
          selftests/unit/utils/cpu.py on lines 130..137
          selftests/unit/utils/cpu.py on lines 139..146
          selftests/unit/utils/cpu.py on lines 148..155
          selftests/unit/utils/cpu.py on lines 183..188
          selftests/unit/utils/cpu.py on lines 190..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 58.

          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

                  class JobLogPost(job.Job):
                      def post_tests(self):
                          with open(
                              os.path.join(self.logdir, "reversed_id"), "w", encoding="utf-8"
                          ) as f:
          Severity: Major
          Found in selftests/unit/job.py and 1 other location - About 2 hrs to fix
          selftests/unit/job.py on lines 211..216

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

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

              def test_power8_get_version(self):
                  with unittest.mock.patch(
                      "avocado.utils.cpu.platform.machine", return_value="powerpc"
                  ):
                      with unittest.mock.patch(
          Severity: Major
          Found in selftests/unit/utils/cpu.py and 5 other locations - About 2 hrs to fix
          selftests/unit/utils/cpu.py on lines 130..137
          selftests/unit/utils/cpu.py on lines 139..146
          selftests/unit/utils/cpu.py on lines 157..164
          selftests/unit/utils/cpu.py on lines 183..188
          selftests/unit/utils/cpu.py on lines 190..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 58.

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

              def test_power8_get_family(self):
                  with unittest.mock.patch("avocado.utils.cpu.get_arch", return_value="powerpc"):
                      with unittest.mock.patch(
                          "builtins.open", return_value=self._get_data_mock("power8")
                      ):
          Severity: Major
          Found in selftests/unit/utils/cpu.py and 5 other locations - About 2 hrs to fix
          selftests/unit/utils/cpu.py on lines 130..137
          selftests/unit/utils/cpu.py on lines 139..146
          selftests/unit/utils/cpu.py on lines 148..155
          selftests/unit/utils/cpu.py on lines 157..164
          selftests/unit/utils/cpu.py on lines 190..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 58.

          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

                      def post_tests(self):
                          with open(
                              os.path.join(self.logdir, "reversed_id"), "w", encoding="utf-8"
                          ) as f:
                              f.write(self.unique_id[::-1])
          Severity: Major
          Found in selftests/unit/job.py and 1 other location - About 2 hrs to fix
          selftests/unit/job.py on lines 172..178

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

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

              def test_power9_get_family(self):
                  with unittest.mock.patch("avocado.utils.cpu.get_arch", return_value="powerpc"):
                      with unittest.mock.patch(
                          "builtins.open", return_value=self._get_data_mock("power9")
                      ):
          Severity: Major
          Found in selftests/unit/utils/cpu.py and 5 other locations - About 2 hrs to fix
          selftests/unit/utils/cpu.py on lines 130..137
          selftests/unit/utils/cpu.py on lines 139..146
          selftests/unit/utils/cpu.py on lines 148..155
          selftests/unit/utils/cpu.py on lines 157..164
          selftests/unit/utils/cpu.py on lines 183..188

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

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

              def test_intel_get_version(self):
                  with unittest.mock.patch(
                      "avocado.utils.cpu.platform.machine", return_value="x86_64"
                  ):
                      with unittest.mock.patch(
          Severity: Major
          Found in selftests/unit/utils/cpu.py and 5 other locations - About 2 hrs to fix
          selftests/unit/utils/cpu.py on lines 130..137
          selftests/unit/utils/cpu.py on lines 148..155
          selftests/unit/utils/cpu.py on lines 157..164
          selftests/unit/utils/cpu.py on lines 183..188
          selftests/unit/utils/cpu.py on lines 190..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 58.

          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_job_empty_has_id(self):
                  config = {"run.results_dir": self.tmpdir.name, "core.show": ["none"]}
                  self.job = job.Job(config)
                  self.job.setup()
                  self.assertIsNotNone(self.job.unique_id)
          Severity: Major
          Found in selftests/unit/job.py and 1 other location - About 2 hrs to fix
          selftests/unit/job.py on lines 88..92

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

          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 service.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #  Copyright(c) 2013 Intel Corporation.
          #
          #  This program is free software; you can redistribute it and/or modify it
          #  under the terms and conditions of the GNU General Public License,
          #  version 2, as published by the Free Software Foundation.
          Severity: Minor
          Found in selftests/unit/utils/service.py - About 2 hrs to fix
            Severity
            Category
            Status
            Source
            Language