cotag/spider-gazelle

View on GitHub
lib/spider-gazelle/spider/http1.rb

Summary

Maintainability
D
2 days
Test Coverage

Method send_next_response has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

            def send_next_response
                request, result = @responses.shift
                @transmitting = request
                return unless request

Severity: Minor
Found in lib/spider-gazelle/spider/http1.rb - About 1 day 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

File http1.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'http-parser'     # C based, fast, http parser
require 'spider-gazelle/gazelle/request'


module SpiderGazelle
Severity: Minor
Found in lib/spider-gazelle/spider/http1.rb - About 3 hrs to fix

    Method send_next_response has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                def send_next_response
                    request, result = @responses.shift
                    @transmitting = request
                    return unless request
    
    
    Severity: Major
    Found in lib/spider-gazelle/spider/http1.rb - About 3 hrs to fix

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

              class Http1
                  class Callbacks
                      def initialize
                          @parser = ::HttpParser::Parser.new self
                          @logger = Logger.instance
      Severity: Minor
      Found in lib/spider-gazelle/spider/http1.rb - About 2 hrs to fix

        Method process_on_gazelle has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                    def process_on_gazelle(request)
                        result = begin
                            request.execute!
                        rescue StandardError => e
                            Logger.instance.print_error e, 'framework error'
        Severity: Minor
        Found in lib/spider-gazelle/spider/http1.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                    def initialize(return_method, callbacks, thread, logger, gazelles)
        Severity: Minor
        Found in lib/spider-gazelle/spider/http1.rb - About 35 mins to fix

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

                      def write_response(request, status, headers, body)
                          keep_alive = request.keep_alive
          
                          if headers['Content-Length']
                              headers['Content-Length'] = headers['Content-Length'].to_s
          Severity: Minor
          Found in lib/spider-gazelle/spider/http1.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 process_next has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                      def process_next
                          @processing = @requests.shift
                          if @processing
                              request = @processing
          
          
          Severity: Minor
          Found in lib/spider-gazelle/spider/http1.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