neglectedvalue/yup

View on GitHub

Showing 11 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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              if pid
                db_closer = proc do
                  Yup.logger.info { "Terminating consumer #{$$}" }
                  Process.kill("KILL", pid)
                  state.dispose()
          Severity: Minor
          Found in lib/yup.rb and 1 other location - About 30 mins to fix
          lib/yup.rb on lines 105..113

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

          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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              if pid
                db_closer = proc do
                  Yup.logger.info { "Terminating consumer #{$$}" }
                  Process.kill("KILL", pid)
                  state.dispose()
          Severity: Minor
          Found in lib/yup.rb and 1 other location - About 30 mins to fix
          lib/yup.rb on lines 70..78

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

          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

          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