avocado-framework/avocado

View on GitHub
avocado/core/test.py

Summary

Maintainability
F
1 wk
Test Coverage
D
64%

File test.py has 1191 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; specifically version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
Severity: Major
Found in avocado/core/test.py - About 3 days to fix

    Function _run_avocado has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Open

        def _run_avocado(self):
            """
            Auxiliary method to run_avocado.
            """
            # If the test contains an output.expected file, it requires
    Severity: Minor
    Found in avocado/core/test.py - About 1 day 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

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

    class Test(unittest.TestCase, TestData):
    
        """
        Base implementation for the test class.
    
    
    Severity: Minor
    Found in avocado/core/test.py - About 6 hrs to fix

      Function _execute_cmd has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          def _execute_cmd(self):
              """
              Run the executable, and log its detailed execution.
              """
              try:
      Severity: Minor
      Found in avocado/core/test.py - About 4 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 _execute_cmd has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def _execute_cmd(self):
              try:
                  test_params = {
                      str(key): str(val)
                      for _, key, val in self.params.iteritems()  # pylint: disable=W1620
      Severity: Minor
      Found in avocado/core/test.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

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

          def get_data(self, filename, source=None, must_exist=True):
              """
              Retrieves the path to a given data file.
      
              This implementation looks for data file in one of the sources
      Severity: Minor
      Found in avocado/core/test.py - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function __init__ has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, methodName='test', name=None, params=None,
                       base_logdir=None, config=None, runner_queue=None, tags=None):
              """
              Initializes the test.
      
      
      Severity: Minor
      Found in avocado/core/test.py - About 1 hr to fix

        Function fetch_asset has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def fetch_asset(self, name, asset_hash=None, algorithm=None,
                            locations=None, expire=None, find_only=False,
                            cancel_on_missing=False):
                """
                Method o call the utils.asset in order to fetch and asset file
        Severity: Minor
        Found in avocado/core/test.py - About 1 hr 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 __init__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, methodName='test', name=None, params=None,
                         base_logdir=None, config=None, runner_queue=None, tags=None):
                """
                Initializes the test.
        
        
        Severity: Minor
        Found in avocado/core/test.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _get_datadir has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_datadir(self, source):
                path_components = self._data_sources_mapping.get(source)
                if path_components is None:
                    return
        
        
        Severity: Minor
        Found in avocado/core/test.py - About 1 hr 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 _check_reference has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _check_reference(self, produced_file_path, reference_file_name,
                                 diff_file_name, child_log_name, name='Content'):
                '''
                Compares the file produced by the test with the reference file
        
        
        Severity: Minor
        Found in avocado/core/test.py - About 55 mins 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, methodName='test', name=None, params=None,
        Severity: Major
        Found in avocado/core/test.py - About 50 mins to fix

          Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, name, params=None, base_logdir=None, config=None,
          Severity: Major
          Found in avocado/core/test.py - About 50 mins to fix

            Function fetch_asset has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def fetch_asset(self, name, asset_hash=None, algorithm=None,
            Severity: Major
            Found in avocado/core/test.py - About 50 mins to fix

              Function run_avocado has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run_avocado(self):
                      """
                      Wraps the run method, for execution inside the avocado runner.
              
                      :result: Unused param, compatibility with :class:`unittest.TestCase`.
              Severity: Minor
              Found in avocado/core/test.py - About 45 mins 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, name, params=None, base_logdir=None, config=None,
              Severity: Minor
              Found in avocado/core/test.py - About 45 mins to fix

                Function _check_reference has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def _check_reference(self, produced_file_path, reference_file_name,
                Severity: Minor
                Found in avocado/core/test.py - About 35 mins to fix

                  Function _register_log_file_handler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def _register_log_file_handler(self, logger, formatter, filename,
                  Severity: Minor
                  Found in avocado/core/test.py - About 35 mins to fix

                    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(self, name, params=None, base_logdir=None, config=None,
                    Severity: Minor
                    Found in avocado/core/test.py - About 35 mins to fix

                      Function _find_result has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _find_result(self, status="OK"):
                              status_line = "[stderr] %s" % status
                              with open(self.logfile) as logfile:
                                  lines = iter(logfile)
                                  for line in lines:
                      Severity: Minor
                      Found in avocado/core/test.py - About 25 mins 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 test has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def test(self):
                              try:
                                  super(PythonUnittest, self).test()
                              except exceptions.TestFail:
                                  status = self._find_result("FAILED")
                      Severity: Minor
                      Found in avocado/core/test.py - About 25 mins 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

                              if (self.filename is not None and
                                      len(os.path.basename(self.filename)) < 251):
                                  file_datadir = self.filename + '.data'
                      Severity: Major
                      Found in avocado/core/test.py and 1 other location - About 2 hrs to fix
                      avocado/core/test.py on lines 103..105

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

                      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

                              if (self.filename is not None and
                                      len(os.path.basename(self.filename)) < 251):
                                  file_datadir = self.filename + '.data'
                      Severity: Major
                      Found in avocado/core/test.py and 1 other location - About 2 hrs to fix
                      avocado/core/test.py on lines 1114..1116

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

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

                                  if skip_location in ['all', 'stdout']:
                                      if re_skip.search(result.stdout_text):
                                          raise exceptions.TestSkipError(skip_msg % 'stdout')
                      Severity: Major
                      Found in avocado/core/test.py and 3 other locations - About 1 hr to fix
                      avocado/core/test.py on lines 1185..1187
                      avocado/core/test.py on lines 1189..1191
                      avocado/core/test.py on lines 1202..1204

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

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

                                      if warn_location in ['all', 'stdout']:
                                          if re_warn.search(result.stdout_text):
                                              raise exceptions.TestWarn(warn_msg % 'stdout')
                      Severity: Major
                      Found in avocado/core/test.py and 3 other locations - About 1 hr to fix
                      avocado/core/test.py on lines 1189..1191
                      avocado/core/test.py on lines 1198..1200
                      avocado/core/test.py on lines 1202..1204

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

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

                                      if warn_location in ['all', 'stderr']:
                                          if re_warn.search(result.stderr_text):
                                              raise exceptions.TestWarn(warn_msg % 'stderr')
                      Severity: Major
                      Found in avocado/core/test.py and 3 other locations - About 1 hr to fix
                      avocado/core/test.py on lines 1185..1187
                      avocado/core/test.py on lines 1198..1200
                      avocado/core/test.py on lines 1202..1204

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

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

                                  if skip_location in ['all', 'stderr']:
                                      if re_skip.search(result.stderr_text):
                                          raise exceptions.TestSkipError(skip_msg % 'stderr')
                      Severity: Major
                      Found in avocado/core/test.py and 3 other locations - About 1 hr to fix
                      avocado/core/test.py on lines 1185..1187
                      avocado/core/test.py on lines 1189..1191
                      avocado/core/test.py on lines 1198..1200

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

                      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

                      There are no issues that match your filters.

                      Category
                      Status