activefx/url_parser

View on GitHub

Showing 11 of 11 total issues

Class Model has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Model

    attr_reader :parsed_uri, :parsed_domain

    def initialize(uri, domain = nil)
Severity: Minor
Found in lib/url_parser/model.rb - About 3 hrs to fix

    Class URI has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class URI
        extend Forwardable
    
        LOCALHOST_REGEXP  = /(\A|\.)localhost\z/
    
    
    Severity: Minor
    Found in lib/url_parser/uri.rb - About 3 hrs to fix

      Method parse has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse
            return uri if uri.is_a?(Addressable::URI)
      
            Addressable::URI.parse(base_uri).tap do |parsed_uri|
              parsed_uri.join!(uri) if @base_uri
      Severity: Minor
      Found in lib/url_parser/parser.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 block_builder has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def block_builder
            proc do |uri|
              if cleaned?
                uri.clean!
              else
      Severity: Minor
      Found in lib/url_parser/uri.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

      Class Parser has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Parser
      
          class << self
      
            def call(uri, options = {}, &blk)
      Severity: Minor
      Found in lib/url_parser/parser.rb - About 2 hrs to fix

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

            def directory
              unless path.nil? || path.empty?
                parts = path.split('/')
                if parts.empty?
                  '/'
        Severity: Minor
        Found in lib/url_parser/model.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 parse has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parse
              return uri if uri.is_a?(Addressable::URI)
        
              Addressable::URI.parse(base_uri).tap do |parsed_uri|
                parsed_uri.join!(uri) if @base_uri
        Severity: Minor
        Found in lib/url_parser/parser.rb - About 1 hr to fix

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

                def call(uri, options = {}, &blk)
                  return nil unless uri
          
                  parser = new(uri, options).tap do |uri|
                    if block_given?
          Severity: Minor
          Found in lib/url_parser/parser.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(uri, domain = nil)
                unless uri.is_a?(Addressable::URI)
                  raise RequiresAddressableURI,
                    "#{uri} must be an Addressable::URI"
                end
          Severity: Minor
          Found in lib/url_parser/model.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 normalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def normalize
                parse.tap do |uri|
                  uri.path      = uri.path.squeeze('/')
                  uri.path      = uri.path.chomp('/') if uri.path.size != 1
                  uri.query     = nil if uri.query && uri.query.empty?
          Severity: Minor
          Found in lib/url_parser/parser.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 suffix has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def suffix
                if path
                  ext = File.extname(path)
                  ext[0] = '' if ext[0] == '.'
                  ext.empty? ? nil : ext
          Severity: Minor
          Found in lib/url_parser/model.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

          Severity
          Category
          Status
          Source
          Language