avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

Function find_python_tests has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def find_python_tests(target_module, target_class, determine_match, path):
    """
    Attempts to find Python tests from source files

    A Python test in this context is a method within a specific type
Severity: Minor
Found in avocado/core/safeloader/core.py - About 3 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

JobTest has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class JobTest(unittest.TestCase):
    def setUp(self):
        self.job = None
        prefix = temp_dir_prefix(self)
        self.tmpdir = tempfile.TemporaryDirectory(prefix=prefix)
Severity: Minor
Found in selftests/unit/job.py - About 3 hrs to fix

    Test has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Test(unittest.TestCase, TestData):
        """
        Base implementation for the test class.
    
        You'll inherit from this to write your own tests. Typically you'll want
    Severity: Minor
    Found in avocado/core/test.py - About 3 hrs to fix

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

          def test_multiple_chunk_size(self, buddy_mocked):
              chunk_size = "2 4"
              result = memory.get_buddy_info(chunk_size)
              self.assertEqual(result["2"], 10048)
              self.assertEqual(result["4"], 19278)
      Severity: Major
      Found in selftests/unit/utils/memory.py and 2 other locations - About 3 hrs to fix
      selftests/unit/utils/memory.py on lines 33..38
      selftests/unit/utils/memory.py on lines 48..53

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

      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

          def test_less_than_chunk_size(self, buddy_mocked):
              chunk_size = "<2"
              result = memory.get_buddy_info(chunk_size)
              self.assertEqual(result["0"], 6418)
              self.assertEqual(result["1"], 10439)
      Severity: Major
      Found in selftests/unit/utils/memory.py and 2 other locations - About 3 hrs to fix
      selftests/unit/utils/memory.py on lines 48..53
      selftests/unit/utils/memory.py on lines 63..68

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

      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

          def test_greater_than_chunk_size(self, buddy_mocked):
              chunk_size = ">3"
              result = memory.get_buddy_info(chunk_size)
              self.assertEqual(result["4"], 19278)
              self.assertEqual(result["5"], 10357)
      Severity: Major
      Found in selftests/unit/utils/memory.py and 2 other locations - About 3 hrs to fix
      selftests/unit/utils/memory.py on lines 33..38
      selftests/unit/utils/memory.py on lines 63..68

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

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

      """
      Assets plugin functional tests
      """
      
      import os
      Severity: Minor
      Found in selftests/functional/plugin/assets.py - About 3 hrs to fix

        File varianter.py has 304 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/varianter.py - About 3 hrs to fix

          Function set_idle_state has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          def set_idle_state(state_number="all", disable=True, setstate=None):
              """
              Set/Reset cpu idle states for all cpus.
          
              :param state_number: cpuidle state number, default: `all` all states
          Severity: Minor
          Found in avocado/utils/cpu.py - About 3 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 Cit.py has 299 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import logging
          import random
          
          from avocado_varianter_cit.CombinationMatrix import CombinationMatrix
          from avocado_varianter_cit.Solver import Solver
          Severity: Minor
          Found in optional_plugins/varianter_cit/avocado_varianter_cit/Cit.py - About 3 hrs to fix

            File data_structures.py has 298 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/data_structures.py - About 3 hrs to fix

              File data_dir.py has 297 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/data_dir.py - About 3 hrs to fix

                Function get_arch has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_arch():
                    """Work out which CPU architecture we're running on."""
                    cpu_table = [
                        (b"^cpu.*(RS64|Broadband Engine)", "powerpc"),
                        (rb"^cpu.*POWER\d+", "powerpc"),
                Severity: Minor
                Found in avocado/utils/cpu.py - About 3 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

                    def test_unexpected(self):
                        events = self.parse_tap("1..1\ninvalid\nok 1")
                        self.assert_plan(events, count=1, late=False)
                        self.assert_test(events, number=1, name="", result=TestResult.PASS)
                        self.assert_last(events)
                Severity: Major
                Found in selftests/unit/tap.py and 2 other locations - About 3 hrs to fix
                selftests/unit/tap.py on lines 189..193
                selftests/unit/tap.py on lines 276..280

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

                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

                    def test_empty_line(self):
                        events = self.parse_tap("1..1\n\nok 1")
                        self.assert_plan(events, count=1, late=False)
                        self.assert_test(events, number=1, name="", result=TestResult.PASS)
                        self.assert_last(events)
                Severity: Major
                Found in selftests/unit/tap.py and 2 other locations - About 3 hrs to fix
                selftests/unit/tap.py on lines 189..193
                selftests/unit/tap.py on lines 282..286

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

                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

                    def test_one_test_early_plan(self):
                        events = self.parse_tap("1..1\nok")
                        self.assert_plan(events, count=1, late=False)
                        self.assert_test(events, number=1, name="", result=TestResult.PASS)
                        self.assert_last(events)
                Severity: Major
                Found in selftests/unit/tap.py and 2 other locations - About 3 hrs to fix
                selftests/unit/tap.py on lines 276..280
                selftests/unit/tap.py on lines 282..286

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

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

                    DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
                      var api     = new DataTable.Api( settings );
                      var classes = settings.oClasses;
                      var lang    = settings.oLanguage.oPaginate;
                      var btnDisplay, btnClass;

                  File nvme.py has 295 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/nvme.py - About 3 hrs to fix

                    File archive.py has 293 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/archive.py - About 3 hrs to fix

                      Function ResizeControl has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function ResizeControl(table) {
                          var tableBorderSize = table.outerWidth() - table.innerWidth();
                          this.resizeData = {
                            isResizing: false,
                            mouseDownFired: false
                      Severity: Major
                      Found in optional_plugins/html/avocado_result_html/templates/avocado_html.js - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language