avocado-framework/avocado

View on GitHub
avocado/core/output.py

Summary

Maintainability
F
3 days
Test Coverage
B
81%

Starting a process with a shell, possible injection detected, security issue.
Open

        self.pipe = os.popen(paginator, 'w')
Severity: Major
Found in avocado/core/output.py by bandit

File output.py has 598 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: Major
Found in avocado/core/output.py - About 1 day to fix

    Function reconfigure has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    def reconfigure(args):
        """
        Adjust logging handlers accordingly to app args and re-log messages.
        """
        def save_handler(logger_name, handler, configuration):
    Severity: Minor
    Found in avocado/core/output.py - About 5 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

        def emit(self, record):
            try:
                msg = self.format(record)
                if record.levelno < logging.INFO:   # Most messages are INFO
                    pass
    Severity: Minor
    Found in avocado/core/output.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 add_log_handler has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def add_log_handler(logger, klass=logging.StreamHandler, stream=sys.stdout,
    Severity: Minor
    Found in avocado/core/output.py - About 35 mins to fix

      Function print_records has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def print_records(self):
              """
              Prints all stored messages as they occurred into streams they were
              produced for.
              """
      Severity: Minor
      Found in avocado/core/output.py - About 35 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self):
              self.HEADER = self.COLOR_BLUE
              self.PASS = self.COLOR_GREEN
              self.SKIP = self.COLOR_YELLOW
              self.FAIL = self.COLOR_RED
      Severity: Minor
      Found in avocado/core/output.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 log_plugin_failures has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def log_plugin_failures(failures):
          """
          Log in the application UI failures to load a set of plugins
      
          :param failures: a list of load failures, usually coming from a
      Severity: Minor
      Found in avocado/core/output.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

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

              if len(stream_level) == 1:
                  level = logging.DEBUG
              else:
                  level = (int(stream_level[1]) if stream_level[1].isdigit()
                           else logging.getLevelName(stream_level[1].upper()))
      Severity: Major
      Found in avocado/core/output.py and 1 other location - About 1 hr to fix
      avocado/core/job.py on lines 221..222

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

      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 interrupt_str(self, msg='INTERRUPT', move=MOVE_BACK):
              """
              Print an interrupt string (red colored).
      
              If the output does not support colors, just return the original string.
      Severity: Major
      Found in avocado/core/output.py and 5 other locations - About 1 hr to fix
      avocado/core/output.py on lines 149..155
      avocado/core/output.py on lines 157..163
      avocado/core/output.py on lines 165..171
      avocado/core/output.py on lines 173..179
      avocado/core/output.py on lines 189..195

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      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 error_str(self, msg='ERROR', move=MOVE_BACK):
              """
              Print a error string (red colored).
      
              If the output does not support colors, just return the original string.
      Severity: Major
      Found in avocado/core/output.py and 5 other locations - About 1 hr to fix
      avocado/core/output.py on lines 149..155
      avocado/core/output.py on lines 157..163
      avocado/core/output.py on lines 165..171
      avocado/core/output.py on lines 181..187
      avocado/core/output.py on lines 189..195

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      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 warn_str(self, msg='WARN', move=MOVE_BACK):
              """
              Print an warning string (yellow colored).
      
              If the output does not support colors, just return the original string.
      Severity: Major
      Found in avocado/core/output.py and 5 other locations - About 1 hr to fix
      avocado/core/output.py on lines 149..155
      avocado/core/output.py on lines 157..163
      avocado/core/output.py on lines 165..171
      avocado/core/output.py on lines 173..179
      avocado/core/output.py on lines 181..187

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

      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 fail_str(self, msg='FAIL', move=MOVE_BACK):
              """
              Print a fail string (red colored).
      
              If the output does not support colors, just return the original string.
      Severity: Major
      Found in avocado/core/output.py and 5 other locations - About 1 hr to fix
      avocado/core/output.py on lines 149..155
      avocado/core/output.py on lines 157..163
      avocado/core/output.py on lines 173..179
      avocado/core/output.py on lines 181..187
      avocado/core/output.py on lines 189..195

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      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 pass_str(self, msg='PASS', move=MOVE_BACK):
              """
              Print a pass string (green colored).
      
              If the output does not support colors, just return the original string.
      Severity: Major
      Found in avocado/core/output.py and 5 other locations - About 1 hr to fix
      avocado/core/output.py on lines 157..163
      avocado/core/output.py on lines 165..171
      avocado/core/output.py on lines 173..179
      avocado/core/output.py on lines 181..187
      avocado/core/output.py on lines 189..195

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      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 skip_str(self, msg='SKIP', move=MOVE_BACK):
              """
              Print a skip string (yellow colored).
      
              If the output does not support colors, just return the original string.
      Severity: Major
      Found in avocado/core/output.py and 5 other locations - About 1 hr to fix
      avocado/core/output.py on lines 149..155
      avocado/core/output.py on lines 165..171
      avocado/core/output.py on lines 173..179
      avocado/core/output.py on lines 181..187
      avocado/core/output.py on lines 189..195

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      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

      TEST_STATUS_DECORATOR_MAPPING = {'PASS': TERM_SUPPORT.pass_str,
                                       'ERROR': TERM_SUPPORT.error_str,
                                       'FAIL': TERM_SUPPORT.fail_str,
                                       'SKIP': TERM_SUPPORT.skip_str,
                                       'WARN': TERM_SUPPORT.warn_str,
      Severity: Minor
      Found in avocado/core/output.py and 1 other location - About 45 mins to fix
      avocado/core/output.py on lines 204..210

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

      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

      TEST_STATUS_MAPPING = {'PASS': TERM_SUPPORT.PASS,
                             'ERROR': TERM_SUPPORT.ERROR,
                             'FAIL': TERM_SUPPORT.FAIL,
                             'SKIP': TERM_SUPPORT.SKIP,
                             'WARN': TERM_SUPPORT.WARN,
      Severity: Minor
      Found in avocado/core/output.py and 1 other location - About 45 mins to fix
      avocado/core/output.py on lines 215..221

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

      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