avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

Function n_tuple has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def n_tuple(node):
        if len(node) == 2:
            # tuple ::= {}
            node.value = {}
        elif len(node) == 3:
Severity: Minor
Found in avocado/utils/external/gdbmi_parser.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

    def test_identifier(self):
        open_mocked = unittest.mock.mock_open(
            read_data=(
                '{"kind": "exec-test", "uri": "/bin/sh", '
                '"args": ["/etc/profile"], '
Severity: Major
Found in selftests/unit/runnable.py and 1 other location - About 2 hrs to fix
selftests/unit/runnable.py on lines 112..116

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

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(self):
        open_mocked = unittest.mock.mock_open(read_data='{"kind": "noop"}')
        with unittest.mock.patch("avocado.core.nrunner.runnable.open", open_mocked):
            runnable = Runnable.from_recipe("fake_path")
        self.assertEqual(runnable.kind, "noop")
Severity: Major
Found in selftests/unit/runnable.py and 1 other location - About 2 hrs to fix
selftests/unit/runnable.py on lines 188..199

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

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

TreeNode has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class TreeNode:
    """
    Class for bounding nodes into tree-structure.
    """

Severity: Minor
Found in avocado/core/tree.py - About 2 hrs to fix

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

        def test_check_pattern_in_file_unsuccessfully(self):
            with tempfile.NamedTemporaryFile(mode="w") as temp_file:
                temp_file.write("123")
                temp_file.seek(0)
                self.assertFalse(genio.is_pattern_in_file(temp_file.name, r"\D{3}"))
    Severity: Major
    Found in selftests/unit/utils/genio.py and 2 other locations - About 2 hrs to fix
    selftests/unit/utils/genio.py on lines 21..25
    selftests/unit/utils/genio.py on lines 27..31

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

    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_check_simple_pattern_in_file_successfully(self):
            with tempfile.NamedTemporaryFile(mode="w") as temp_file:
                temp_file.write("Hello World")
                temp_file.seek(0)
                self.assertTrue(genio.is_pattern_in_file(temp_file.name, "Hello"))
    Severity: Major
    Found in selftests/unit/utils/genio.py and 2 other locations - About 2 hrs to fix
    selftests/unit/utils/genio.py on lines 27..31
    selftests/unit/utils/genio.py on lines 33..37

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

    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_check_pattern_in_file_successfully(self):
            with tempfile.NamedTemporaryFile(mode="w") as temp_file:
                temp_file.write("123")
                temp_file.seek(0)
                self.assertTrue(genio.is_pattern_in_file(temp_file.name, r"\d{3}"))
    Severity: Major
    Found in selftests/unit/utils/genio.py and 2 other locations - About 2 hrs to fix
    selftests/unit/utils/genio.py on lines 21..25
    selftests/unit/utils/genio.py on lines 33..37

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

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

      Function create_suites has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_suites(args):  # pylint: disable=W0621
          suites = []
          config_check = {"run.ignore_missing_references": True}
      
          if args.dict_tests["static-checks"]:
      Severity: Minor
      Found in selftests/check.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 _monitor has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def _monitor(proc, time_started, queue):
              timeout = float("inf")
              next_status_time = None
              while True:
                  time.sleep(RUNNER_RUN_CHECK_INTERVAL)
      Severity: Minor
      Found in avocado/plugins/runners/avocado_instrumented.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 _update_zip_extra_attrs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def _update_zip_extra_attrs(self, dst_dir):
              if platform.system() != "Linux":
                  LOG.warning("Attr handling in zip files only supported on Linux.")
                  return
              # Walk all files and re-create files as symlinks
      Severity: Minor
      Found in avocado/utils/archive.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 __enter__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def __enter__(self):
              flags = os.O_CREAT | os.O_EXCL | os.O_WRONLY | os.O_SYNC
              timelimit = time.monotonic() + self.timeout
              while True:
                  try:
      Severity: Minor
      Found in avocado/utils/filelock.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 makeNewRules has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def makeNewRules(self):
              worklist = []
              for rulelist in self.rules.values():
                  for rule in rulelist:
                      worklist.append((rule, 0, 1, rule))
      Severity: Minor
      Found in avocado/utils/external/spark.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

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

              possible_numbers = list(range(0, row[column_index])) + list(
                  range(row[column_index] + 1, self.data[column_index])
      Severity: Major
      Found in optional_plugins/varianter_cit/avocado_varianter_cit/Cit.py and 1 other location - About 2 hrs to fix
      optional_plugins/varianter_cit/avocado_varianter_cit/Cit.py on lines 295..296

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

      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

                      possible_numbers = list(range(0, row[column_index])) + list(
                          range(row[column_index] + 1, self.data[column_index])
      Severity: Major
      Found in optional_plugins/varianter_cit/avocado_varianter_cit/Cit.py and 1 other location - About 2 hrs to fix
      optional_plugins/varianter_cit/avocado_varianter_cit/Cit.py on lines 283..284

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

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

      import os
      import sys
      import time
      import unittest
      
      
      Severity: Minor
      Found in selftests/functional/nrunner.py - About 2 hrs to fix

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

            def test_filtering_node(self, buddy_mocked):
                chunk_size = "0"
                result = memory.get_buddy_info(chunk_size, nodes="1")
                self.assertEqual(result[chunk_size], 5430)
                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 96..100

        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

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

            def test_decode_response(self):
                self.assertEqual(GDBRemote.decode(b"$!#21"), b"!")
                self.assertEqual(GDBRemote.decode(b"$OK#9a"), b"OK")
                self.assertEqual(GDBRemote.decode(b"$foo#44"), b"foo")
        Severity: Major
        Found in selftests/unit/utils/gdb.py and 2 other locations - About 2 hrs to fix
        selftests/unit/utils/gdb.py on lines 7..10
        selftests/unit/utils/gdb.py on lines 12..15

        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

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

            def test_encode_command(self):
                self.assertEqual(GDBRemote.encode(b"!"), b"$!#21")
                self.assertEqual(GDBRemote.encode(b"OK"), b"$OK#9a")
                self.assertEqual(GDBRemote.encode(b"foo"), b"$foo#44")
        Severity: Major
        Found in selftests/unit/utils/gdb.py and 2 other locations - About 2 hrs to fix
        selftests/unit/utils/gdb.py on lines 7..10
        selftests/unit/utils/gdb.py on lines 17..20

        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

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

            def test_checksum(self):
                self.assertEqual(GDBRemote.checksum(b"!"), b"21")
                self.assertEqual(GDBRemote.checksum(b"OK"), b"9a")
                self.assertEqual(GDBRemote.checksum(b"foo"), b"44")
        Severity: Major
        Found in selftests/unit/utils/gdb.py and 2 other locations - About 2 hrs to fix
        selftests/unit/utils/gdb.py on lines 12..15
        selftests/unit/utils/gdb.py on lines 17..20

        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

        Severity
        Category
        Status
        Source
        Language