hackedteam/vector-edk

View on GitHub
AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.py

Summary

Maintainability
F
1 mo
Test Coverage

File message.py has 616 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright (C) 2001-2006 Python Software Foundation
# Author: Barry Warsaw
# Contact: email-sig@python.org

"""Basic message object for the email package object model."""
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.py - About 1 day to fix

    Message has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Message:
        """Basic message object.
    
        A message object is defined as something that has a bunch of RFC 2822
        headers and a payload.  It may optionally have an envelope header
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.py - About 5 hrs to fix

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

          def set_param(self, param, value, header='Content-Type', requote=True,
                        charset=None, language=''):
              """Set a parameter in the Content-Type header.
      
              If the parameter already exists in the header, its value will be
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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 set_boundary has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_boundary(self, boundary):
              """Set the boundary parameter in Content-Type to 'boundary'.
      
              This is subtly different than deleting the Content-Type header and
              adding a new one with a new boundary parameter via add_header().  The
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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 get_payload has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_payload(self, i=None, decode=False):
              """Return a reference to the payload.
      
              The payload will either be a list object or a string.  If you mutate
              the list object, you modify the message's payload in place.  Optional
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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 set_charset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_charset(self, charset):
              """Set the charset of the payload to a given character set.
      
              charset can be a Charset instance, a string naming a character set, or
              None.  If it is a string it will be converted to a Charset instance.
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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 del_param has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def del_param(self, param, header='content-type', requote=True):
              """Remove the given parameter completely from the Content-Type header.
      
              The header will be re-written in place without the parameter or its
              value. All values will be quoted as necessary unless requote is
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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 _formatparam has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def _formatparam(param, value=None, quote=True):
          """Convenience function to format and return a key=value pair.
      
          This will quote the value if needed or if quote is true.  If value is a
          three tuple (charset, language, value), it will be encoded according
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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 _parseparam has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def _parseparam(s):
          plist = []
          while s[:1] == ';':
              s = s[1:]
              end = s.find(';')
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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 get_param has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_param(self, param, failobj=None, header='content-type',
                        unquote=True):
              """Return the parameter value if found in the Content-Type header.
      
              Optional failobj is the object to return if there is no Content-Type
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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 set_param has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def set_param(self, param, value, header='Content-Type', requote=True,
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.py - About 45 mins to fix

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

            def get_content_charset(self, failobj=None):
                """Return the charset parameter of the Content-Type header.
        
                The returned string is always coerced to lower case.  If there is no
                Content-Type header, or if that header has no charset parameter,
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.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

        Avoid too many return statements within this function.
        Open

                return payload
        Severity: Major
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return payload
          Severity: Major
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/email/message.py - About 30 mins to fix

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

            vector-uefi/fd/efi/StdLib/lib/python.27/email/message.py on lines 0..797

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

            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