neglectedvalue/yup

View on GitHub

Showing 9 of 11 total issues

Method make_request has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def make_request(req)
        begin
          @http_method, @request_url, headers, body = req
          headers = Hash[*headers.to_a.flatten.map(&:to_s)]
          headers["Host"]       = @forward_to
Severity: Minor
Found in lib/yup/state.rb - About 1 hr to fix

    Method perform has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def perform
          http_method = @http_method.to_sym
          http_url    = "http://#{@forward_to}#{@request_url}"
          http = EventMachine::HttpRequest.
            new(http_url,
    Severity: Minor
    Found in lib/yup/request_forwarder.rb - About 1 hr to fix

      Method run_with_bdb has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.run_with_bdb(config)
          require 'yup/state/bdb'
      
          host        = config[:listen_host] || 'localhost'
          port        = config[:listen_port] || 8080
      Severity: Minor
      Found in lib/yup.rb - About 1 hr to fix

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

              def log_response(raw_response, body, http)
                @logger.info { "HTTP request: #{@http_method.upcase} #{@request_url} HTTP/1.1" }
                if raw_response && !raw_response.empty?
                  @logger.info  { "HTTP response: #{raw_response.lines.first.chomp}" }
                  @logger.debug { "HTTP response headers" + (http.headers.empty? ? " is empty" : "\n" + http.headers.inspect) }
        Severity: Minor
        Found in lib/yup/state.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 log_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def log_response(http)
              @logger.info { "HTTP request: #{@http_method.upcase} #{@request_url} HTTP/1.1" }
              if http.response_header.http_status
                @logger.info  { "HTTP response: HTTP/#{http.response_header.http_version} #{http.response_header.http_status} #{http.response_header.http_reason}" }
                @logger.debug { "HTTP response headers" + (http.response_header.empty? ? " is empty" : "\n" + http.response_header.inspect) }
        Severity: Minor
        Found in lib/yup/request_forwarder.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(http_method, request_url, headers, body, forward_to, timeout)
        Severity: Minor
        Found in lib/yup/request_forwarder.rb - About 45 mins to fix

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

                def make_request(req)
                  begin
                    @http_method, @request_url, headers, body = req
                    headers = Hash[*headers.to_a.flatten.map(&:to_s)]
                    headers["Host"]       = @forward_to
          Severity: Minor
          Found in lib/yup/state.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 perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def perform
                http_method = @http_method.to_sym
                http_url    = "http://#{@forward_to}#{@request_url}"
                http = EventMachine::HttpRequest.
                  new(http_url,
          Severity: Minor
          Found in lib/yup/request_forwarder.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 on_message_complete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def on_message_complete
                @logger.info  {
                  "Processing a new request: #{@parser.http_method} #{@parser.request_url} HTTP/#{@parser.http_version.join('.')}"
                }
                @logger.debug {
          Severity: Minor
          Found in lib/yup/request_handler.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