rubygems/rubygems

View on GitHub
lib/rubygems/vendor/uri/lib/uri/generic.rb

Summary

Maintainability
F
1 wk
Test Coverage

File generic.rb has 770 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative 'common'
autoload :IPSocket, 'socket'
autoload :IPAddr, 'ipaddr'

module Gem::URI
Severity: Major
Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 1 day to fix

    Class Generic has 72 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Generic
        include Gem::URI
    
        #
        # A Default port of nil for Gem::URI::Generic.
    Severity: Major
    Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 1 day to fix

      Method find_proxy has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_proxy(env=ENV)
            raise BadURIError, "relative Gem::URI: #{self}" if self.relative?
            name = self.scheme.downcase + '_proxy'
            proxy_uri = nil
            if name == 'http_proxy' && env.include?('REQUEST_METHOD') # CGI?
      Severity: Minor
      Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - 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

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

          def self.use_proxy?(hostname, addr, port, no_proxy) # :nodoc:
            hostname = hostname.downcase
            dothostname = ".#{hostname}"
            no_proxy.scan(/([^:,\s]+)(?::(\d+))?/) {|p_host, p_port|
              if !p_port || port == p_port.to_i
      Severity: Minor
      Found in lib/rubygems/vendor/uri/lib/uri/generic.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 merge_path has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def merge_path(base, rel)
      
            # RFC2396, Section 5.2, 5)
            # RFC2396, Section 5.2, 6)
            base_path = split_path(base)
      Severity: Minor
      Found in lib/rubygems/vendor/uri/lib/uri/generic.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 merge has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def merge(oth)
            rel = parser.__send__(:convert_to_uri, oth)
      
            if rel.absolute?
              #raise BadURIError, "both Gem::URI are absolute" if absolute?
      Severity: Minor
      Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - 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

      Method find_proxy has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def find_proxy(env=ENV)
            raise BadURIError, "relative Gem::URI: #{self}" if self.relative?
            name = self.scheme.downcase + '_proxy'
            proxy_uri = nil
            if name == 'http_proxy' && env.include?('REQUEST_METHOD') # CGI?
      Severity: Major
      Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 2 hrs to fix

        Method route_from0 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def route_from0(oth)
              oth = parser.__send__(:convert_to_uri, oth)
              if self.relative?
                raise BadURIError,
                  "relative Gem::URI: #{self}"
        Severity: Minor
        Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - 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

        Method to_s has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_s
              str = ''.dup
              if @scheme
                str << @scheme
                str << ':'
        Severity: Minor
        Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - 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

        Method build2 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.build2(args)
              begin
                return self.build(args)
              rescue InvalidComponentError
                if args.kind_of?(Array)
        Severity: Minor
        Found in lib/rubygems/vendor/uri/lib/uri/generic.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 merge_path has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def merge_path(base, rel)
        
              # RFC2396, Section 5.2, 5)
              # RFC2396, Section 5.2, 6)
              base_path = split_path(base)
        Severity: Minor
        Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 1 hr to fix

          Method route_from0 has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def route_from0(oth)
                oth = parser.__send__(:convert_to_uri, oth)
                if self.relative?
                  raise BadURIError,
                    "relative Gem::URI: #{self}"
          Severity: Minor
          Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 1 hr to fix

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

                def initialize(scheme,
                               userinfo, host, port, registry,
                               path, opaque,
                               query,
                               fragment,
            Severity: Minor
            Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 1 hr to fix

              Method initialize has 11 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def initialize(scheme,
                                 userinfo, host, port, registry,
                                 path, opaque,
                                 query,
                                 fragment,
              Severity: Major
              Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 1 hr to fix

                Method to_s has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def to_s
                      str = ''.dup
                      if @scheme
                        str << @scheme
                        str << ':'
                Severity: Minor
                Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 1 hr to fix

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

                      def self.build(args)
                        if args.kind_of?(Array) &&
                            args.size == ::Gem::URI::Generic::COMPONENT.size
                          tmp = args.dup
                        elsif args.kind_of?(Hash)
                  Severity: Minor
                  Found in lib/rubygems/vendor/uri/lib/uri/generic.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 merge has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def merge(oth)
                        rel = parser.__send__(:convert_to_uri, oth)
                  
                        if rel.absolute?
                          #raise BadURIError, "both Gem::URI are absolute" if absolute?
                  Severity: Minor
                  Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 1 hr to fix

                    Method route_from_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def route_from_path(src, dst)
                          case dst
                          when src
                            # RFC2396, Section 4.2
                            return ''
                    Severity: Minor
                    Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - 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

                    Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(scheme,
                                       userinfo, host, port, registry,
                                       path, opaque,
                                       query,
                                       fragment,
                    Severity: Minor
                    Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - 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

                    Avoid too many return statements within this method.
                    Open

                            return rel, rel
                    Severity: Major
                    Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return '../' * src_path.size + tmp
                      Severity: Major
                      Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                  return tmp
                        Severity: Major
                        Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                return oth, rel
                          Severity: Major
                          Found in lib/rubygems/vendor/uri/lib/uri/generic.rb - About 30 mins to fix

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

                                def check_opaque(v)
                                  return v unless v
                            
                                  # raise if both hier and opaque are not nil, because:
                                  # absoluteURI   = scheme ":" ( hier_part | opaque_part )
                            Severity: Minor
                            Found in lib/rubygems/vendor/uri/lib/uri/generic.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 check_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def check_path(v)
                                  # raise if both hier and opaque are not nil, because:
                                  # absoluteURI   = scheme ":" ( hier_part | opaque_part )
                                  # hier_part     = ( net_path | abs_path ) [ "?" query ]
                                  if v && @opaque
                            Severity: Minor
                            Found in lib/rubygems/vendor/uri/lib/uri/generic.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 set_port has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def set_port(v)
                                  v = v.empty? ? nil : v.to_i unless !v || v.kind_of?(Integer)
                                  @port = v
                                end
                            Severity: Minor
                            Found in lib/rubygems/vendor/uri/lib/uri/generic.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 query= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def query=(v)
                                  return @query = nil unless v
                                  raise InvalidURIError, "query conflicts with opaque" if @opaque
                            
                                  x = v.to_str
                            Severity: Minor
                            Found in lib/rubygems/vendor/uri/lib/uri/generic.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