trusche/httplog

View on GitHub

Showing 13 of 13 total issues

File http_log.rb has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'net/http'
require 'logger'
require 'benchmark'
require 'rainbow'
require 'rack'
Severity: Minor
Found in lib/httplog/http_log.rb - About 3 hrs to fix

    Method parse_body has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_body(body, mask_body, encoding, content_type)
          raise BodyParsingError, "(not showing binary data)" unless text_based?(content_type)
    
    
          if body.is_a?(Net::ReadAdapter)
    Severity: Minor
    Found in lib/httplog/http_log.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 colorize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def colorize(msg)
          return msg unless config.color
          if config.color.is_a?(Hash)
            msg = Rainbow(msg).color(config.color[:color]) if config.color[:color]
            msg = Rainbow(msg).bg(config.color[:background]) if config.color[:background]
    Severity: Minor
    Found in lib/httplog/http_log.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 request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def request(req, body = nil, &block)
          url = "http://#{@address}:#{@port}#{req.path}"
    
          bm = Benchmark.realtime do
            @response = orig_request(req, body, &block)
    Severity: Minor
    Found in lib/httplog/adapters/net_http.rb - About 1 hr to fix

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

          def parse_body(body, mask_body, encoding, content_type)
            raise BodyParsingError, "(not showing binary data)" unless text_based?(content_type)
      
      
            if body.is_a?(Net::ReadAdapter)
      Severity: Minor
      Found in lib/httplog/http_log.rb - About 1 hr to fix

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

            def do_get_block(req, proxy, conn, &block)
              retryable_response = nil
              bm = Benchmark.realtime do
                begin
                  orig_do_get_block(req, proxy, conn, &block)
        Severity: Minor
        Found in lib/httplog/adapters/httpclient.rb - About 1 hr to fix

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

              def do_get_block(req, proxy, conn, &block)
                retryable_response = nil
                bm = Benchmark.realtime do
                  begin
                    orig_do_get_block(req, proxy, conn, &block)
          Severity: Minor
          Found in lib/httplog/adapters/httpclient.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 connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def connect
                  host = @data[:proxy] ? @data[:proxy][:host] : @data[:host]
                  port = @data[:proxy] ? @data[:proxy][:port] : @data[:port]
                  HttpLog.log_connection(host, port) if ::HttpLog.url_approved?(httplog_url(@data))
                  orig_connect
          Severity: Minor
          Found in lib/httplog/adapters/excon.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 request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def request(req, body = nil, &block)
                url = "http://#{@address}:#{@port}#{req.path}"
          
                bm = Benchmark.realtime do
                  @response = orig_request(req, body, &block)
          Severity: Minor
          Found in lib/httplog/adapters/net_http.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 masked has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def masked(msg, key=nil)
                return msg if config.filter_parameters.empty?
                return msg if msg.nil?
          
                # If a key is given, msg is just the value and can be replaced
          Severity: Minor
          Found in lib/httplog/http_log.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 log_body has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def log_body(body, mask_body, encoding = nil, content_type = nil)
                return unless config.log_response
          
                data = parse_body(body, mask_body, encoding, content_type)
          
          
          Severity: Minor
          Found in lib/httplog/http_log.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 masked_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def masked_data msg
                case msg
                when Hash
                  Hash[msg.map { |k, v| [k, config.filter_parameters.include?(k.downcase) ? PARAM_MASK : masked_data(v)] }]
                when Array
          Severity: Minor
          Found in lib/httplog/http_log.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 parse_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_request(options)
                return if options[:request_body].nil?
          
                # Downcase content-type and content-encoding because ::HTTP returns "Content-Type" and "Content-Encoding"
                headers = options[:request_headers].find_all do |header, _|
          Severity: Minor
          Found in lib/httplog/http_log.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