rubygems/rubygems

View on GitHub
lib/rubygems/vendor/net-http/lib/net/http.rb

Summary

Maintainability
F
6 days
Test Coverage

File http.rb has 745 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative '../../../net-protocol/lib/net/protocol'
require_relative '../../../uri/lib/uri'
require_relative '../../../resolv/lib/resolv'
autoload :OpenSSL, 'openssl'

Severity: Major
Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 1 day to fix

    Class HTTP has 77 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class HTTP < Protocol
    
        # :stopdoc:
        VERSION = "0.4.0"
        HTTPVersion = '1.1'
    Severity: Major
    Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 1 day to fix

      Method connect has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

          def connect
            if use_ssl?
              # reference early to load OpenSSL before connecting,
              # as OpenSSL may take time to load.
              @ssl_context = OpenSSL::SSL::SSLContext.new
      Severity: Minor
      Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 7 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

      Method transport_request has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          def transport_request(req)
            count = 0
            begin
              begin_transport req
              res = catch(:response) {
      Severity: Minor
      Found in lib/rubygems/vendor/net-http/lib/net/http.rb - 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

      Method connect has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def connect
            if use_ssl?
              # reference early to load OpenSSL before connecting,
              # as OpenSSL may take time to load.
              @ssl_context = OpenSSL::SSL::SSLContext.new
      Severity: Major
      Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 3 hrs to fix

        Method transport_request has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def transport_request(req)
              count = 0
              begin
                begin_transport req
                res = catch(:response) {
        Severity: Minor
        Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 1 hr to fix

          Method initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(address, port = nil) # :nodoc:
                @address = address
                @port    = (port || HTTP.default_port)
                @ipaddr = nil
                @local_host = nil
          Severity: Minor
          Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 1 hr to fix

            Method start has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def HTTP.start(address, *arg, &block) # :yield: +http+
                  arg.pop if opt = Hash.try_convert(arg[-1])
                  port, p_addr, p_port, p_user, p_pass = *arg
                  p_addr = :ENV if arg.size < 2
                  port = https_default_port if !port && opt && opt[:use_ssl]
            Severity: Minor
            Found in lib/rubygems/vendor/net-http/lib/net/http.rb - 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

            Method request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def request(req, body = nil, &block)  # :yield: +response+
                  unless started?
                    start {
                      req['connection'] ||= 'close'
                      return request(req, body, &block)
            Severity: Minor
            Found in lib/rubygems/vendor/net-http/lib/net/http.rb - 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

            Method begin_transport has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def begin_transport(req)
                  if @socket.closed?
                    connect
                  elsif @last_communicated
                    if @last_communicated + @keep_alive_timeout < Process.clock_gettime(Process::CLOCK_MONOTONIC)
            Severity: Minor
            Found in lib/rubygems/vendor/net-http/lib/net/http.rb - 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

            Method new has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil)
            Severity: Major
            Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 50 mins to fix

              Method send_entity has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def send_entity(path, data, initheader, dest, type, &block)
              Severity: Minor
              Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 45 mins to fix

                Method post has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def post(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
                Severity: Minor
                Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 35 mins to fix

                  Method patch has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
                  Severity: Minor
                  Found in lib/rubygems/vendor/net-http/lib/net/http.rb - About 35 mins to fix

                    Method sspi_auth? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def sspi_auth?(res)
                          return false unless @sspi_enabled
                          if res.kind_of?(HTTPProxyAuthenticationRequired) and
                              proxy? and res["Proxy-Authenticate"].include?("Negotiate")
                            begin
                    Severity: Minor
                    Found in lib/rubygems/vendor/net-http/lib/net/http.rb - 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

                    Method new has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil)
                          http = super address, port
                    
                          if proxy_class? then # from Gem::Net::HTTP::Proxy()
                            http.proxy_from_env = @proxy_from_env
                    Severity: Minor
                    Found in lib/rubygems/vendor/net-http/lib/net/http.rb - 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

                    Method Proxy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil) #:nodoc:
                          return self unless p_addr
                    
                          Class.new(self) {
                            @is_proxy_class = true
                    Severity: Minor
                    Found in lib/rubygems/vendor/net-http/lib/net/http.rb - 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

                    Method edit_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def edit_path(path)
                          if proxy?
                            if path.start_with?("ftp://") || use_ssl?
                              path
                            else
                    Severity: Minor
                    Found in lib/rubygems/vendor/net-http/lib/net/http.rb - 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

                    There are no issues that match your filters.

                    Category
                    Status