hackedteam/vector-edk

View on GitHub
vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py

Summary

Maintainability
F
2 mos
Test Coverage

File httplib.py has 986 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""HTTP/1.1 client library

<intro stuff goes here>
<other stuff, too>
Severity: Major
Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 2 days to fix

    Function begin has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        def begin(self):
            if self.msg is not None:
                # we've already started reading the response
                return
    
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 putrequest has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
            """Send a request to the server.
    
            `method' specifies an HTTP request method, e.g. 'GET'.
            `url' specifies the object being requested, e.g. '/index.html'.
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 readheaders has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def readheaders(self):
            """Read header lines.
    
            Read header lines up to the entirely blank line that terminates them.
            The (normally blank) line that ends the headers is skipped, but not
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 _read_chunked has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def _read_chunked(self, amt):
            assert self.chunked != _UNKNOWN
            chunk_left = self.chunk_left
            value = []
            while True:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 test has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def test():
        """Test this module.
    
        A hodge podge of tests collected here, because they have too many
        external dependencies for the regular test suite.
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 read has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def read(self, amt=None):
            if self.fp is None:
                return ''
    
            if self._method == 'HEAD':
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 _read_status has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _read_status(self):
            # Initialize with Simple-Response defaults
            line = self.fp.readline()
            if self.debuglevel > 0:
                print "reply:", repr(line)
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 send has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def send(self, data):
            """Send `data' to the server."""
            if self.sock is None:
                if self.auto_open:
                    self.connect()
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 test has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def test():
        """Test this module.
    
        A hodge podge of tests collected here, because they have too many
        external dependencies for the regular test suite.
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 1 hr to fix

      Function _set_hostport has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _set_hostport(self, host, port):
              if port is None:
                  i = host.rfind(':')
                  j = host.rfind(']')         # ipv6 addresses have [...]
                  if i > j:
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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, host, port=None, key_file=None, cert_file=None,
      Severity: Major
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 50 mins to fix

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

            def read(self, amt=None):
                if self._line_consumed:
                    return self._file.read(amt)
                assert self._line_left
                if amt is None or amt > self._line_left:
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 getresponse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def getresponse(self, buffering=False):
                "Get the response from the server."
        
                # if a prior response has been completed, then forget about it.
                if self.__response and self.__response.isclosed():
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def __init__(self, host='', port=None, key_file=None, cert_file=None,
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 35 mins to fix

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

              def __init__(self, sock, debuglevel=0, strict=0, method=None, buffering=False):
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 35 mins to fix

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

                def __init__(self, host, port=None, strict=None,
            Severity: Minor
            Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 35 mins to fix

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

                  def _tunnel(self):
                      self._set_hostport(self._tunnel_host, self._tunnel_port)
                      self.send("CONNECT %s:%d HTTP/1.0\r\n" % (self.host, self.port))
                      for header, value in self._tunnel_headers.iteritems():
                          self.send("%s: %s\r\n" % (header, value))
              Severity: Minor
              Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 _set_content_length has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _set_content_length(self, body):
                      # Set the content-length based on the body.
                      thelen = None
                      try:
                          thelen = str(len(body))
              Severity: Minor
              Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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 False
              Severity: Major
              Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return s
                Severity: Major
                Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return True
                  Severity: Major
                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py - About 30 mins to fix

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

                        def _check_close(self):
                            conn = self.msg.getheader('connection')
                            if self.version == 11:
                                # An HTTP/1.1 proxy is assumed to stay open unless
                                # explicitly closed.
                    Severity: Minor
                    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.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

                    Severity: Major
                    Found in vector-uefi/fd/efi/StdLib/lib/python.27/httplib.py and 1 other location - About 2 mos to fix
                    AppPkg/Applications/Python/Python-2.7.2/Lib/httplib.py on lines 0..1392

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

                    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