hackedteam/vector-edk

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

Summary

Maintainability
F
3 mos
Test Coverage

File urllib2.py has 1024 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""An extensible library for opening URLs using a variety of protocols

The simplest way to use this module is to call the urlopen function,
which accepts a string containing a URL or a Request object (described
below).  It opens the URL and returns the results as file-like
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 2 days to fix

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

    def build_opener(*handlers):
        """Create an opener object from a list of handlers.
    
        The opener will use several default handlers, including support
        for HTTP, FTP and when applicable, HTTPS.
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 add_handler has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_handler(self, handler):
            if not hasattr(handler, "add_parent"):
                raise TypeError("expected BaseHandler instance, got %r" %
                                type(handler))
    
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 ftp_open has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def ftp_open(self, req):
            import ftplib
            import mimetypes
            host = req.get_host()
            if not host:
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 parse_http_list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_http_list(s):
        """Parse lists as described by RFC 2068 Section 2.
    
        In particular, parse comma-separated lists where the elements of
        the list may include quoted-strings.  A quoted-string could
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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_authorization has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_authorization(self, req, chal):
            try:
                realm = chal['realm']
                nonce = chal['nonce']
                qop = chal.get('qop')
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 http_error_302 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def http_error_302(self, req, fp, code, msg, headers):
            # Some servers (incorrectly) return multiple Location headers
            # (so probably same goes for URI).  Use first header.
            if 'location' in headers:
                newurl = headers.getheaders('location')[0]
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 http_error_auth_reqed has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def http_error_auth_reqed(self, authreq, host, req, headers):
            # host may be an authority (without userinfo) or a URL with an
            # authority
            # XXX could be multiple headers
            authreq = headers.get(authreq, None)
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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_cache has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_cache(self):
            # first check for old ones
            t = time.time()
            if self.soonest <= t:
                for k, v in self.timeout.items():
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 do_request_ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_request_(self, request):
            host = request.get_host()
            if not host:
                raise URLError('no host given')
    
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 find_user_password has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_user_password(self, realm, authuri):
            domains = self.passwd.get(realm, {})
            for default_port in True, False:
                reduced_authuri = self.reduce_uri(authuri, default_port)
                for uris, authinfo in domains.iteritems():
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 redirect_request has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def redirect_request(self, req, fp, code, msg, headers, newurl):
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 45 mins to fix

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

          def open_local_file(self, req):
              import email.utils
              import mimetypes
              host = req.get_host()
              filename = req.get_selector()
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 connect_ftp has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def connect_ftp(self, user, passwd, host, port, dirs, timeout):
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 45 mins to fix

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

        def _parse_proxy(proxy):
            """Return (scheme, user, password, host/port) given a URL or an authority.
        
            If a URL is supplied, it must have an authority (host:port) component.
            According to RFC 3986, having an authority component means the URL must
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 connect_ftp has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def connect_ftp(self, user, passwd, host, port, dirs, timeout):
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 45 mins to fix

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

              def __init__(self, url, code, msg, hdrs, fp):
          Severity: Minor
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 35 mins to fix

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

                def http_error_302(self, req, fp, code, msg, headers):
            Severity: Minor
            Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 35 mins to fix

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

                  def http_error_default(self, req, fp, code, msg, hdrs):
              Severity: Minor
              Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 35 mins to fix

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

                    def http_error_407(self, req, fp, code, msg, headers):
                Severity: Minor
                Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 35 mins to fix

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

                      def http_error_401(self, req, fp, code, msg, headers):
                  Severity: Minor
                  Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 35 mins to fix

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

                        def __init__(self, url, data=None, headers={},
                    Severity: Minor
                    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 35 mins to fix

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

                          def http_error_401(self, req, fp, code, msg, headers):
                      Severity: Minor
                      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 35 mins to fix

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

                            def http_error_407(self, req, fp, code, msg, headers):
                        Severity: Minor
                        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py - About 35 mins to fix

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

                              def proxy_open(self, req, proxy, type):
                                  orig_type = req.get_type()
                                  proxy_type, user, password, hostport = _parse_proxy(proxy)
                          
                                  if proxy_type is None:
                          Severity: Minor
                          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 reduce_uri has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def reduce_uri(self, uri, default_port=True):
                                  """Accept authority or URI and extract only the authority and path."""
                                  # note HTTP URLs do not have a userinfo component
                                  parts = urlparse.urlsplit(uri)
                                  if parts[1]:
                          Severity: Minor
                          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 open has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
                                  # accept a URL or a Request object
                                  if isinstance(fullurl, basestring):
                                      req = Request(fullurl, data)
                                  else:
                          Severity: Minor
                          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 do_open has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def do_open(self, http_class, req):
                                  """Return an addinfourl object for the request, using http_class.
                          
                                  http_class must implement the HTTPConnection API from httplib.
                                  The addinfourl return value is a file-like object.  It also
                          Severity: Minor
                          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.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 AppPkg/Applications/Python/Python-2.7.2/Lib/urllib2.py and 1 other location - About 2 mos to fix
                          vector-uefi/fd/efi/StdLib/lib/python.27/urllib2.py on lines 0..1448

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

                          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