<commit_before>module Dox
  module Entities
    class Example
      extend Forwardable

      def_delegator :response, :status, :response_status
      def_delegator :response, :content_type, :response_content_type
      def_delegator :response, :body, :response_body
      def_delegator :request, :content_type, :request_content_type
      def_delegator :request, :method, :request_method

      def initialize(details, request, response)
        @desc = details[:description]
        @request = request
        @response = response
      end

      def request_parameters
        request.parameters
               .except(*request.path_parameters.keys.map(&:to_s))
               .except(*request.query_parameters.keys.map(&:to_s))
      end

      def request_identifier
        @desc
      end

      def response_headers
        @response_headers ||= filter_headers(response)
      end

      def request_headers
        @request_headers ||= filter_headers(request)
      end

      def request_fullpath
        if request.query_parameters.present?
          "#{request.path}?#{request_url_query_parameters}"
        else
          request.path
        end
      end

      private

      attr_reader :desc, :request, :response

      def filter_headers(obj)
        headers_whitelist.map do |header|
          header_val = obj.headers[header]
          next if header_val.blank?

          [header, header_val]
        end.compact
      end

      def headers_whitelist
        @headers_whitelist ||= Dox.full_headers_whitelist
      end

      def request_url_query_parameters
        CGI.unescape(request.query_parameters.to_query)
      end
    end
  end
end
<commit_msg>Add comment on the request_fullpath method<commit_after>module Dox
  module Entities
    class Example
      extend Forwardable

      def_delegator :response, :status, :response_status
      def_delegator :response, :content_type, :response_content_type
      def_delegator :response, :body, :response_body
      def_delegator :request, :content_type, :request_content_type
      def_delegator :request, :method, :request_method

      def initialize(details, request, response)
        @desc = details[:description]
        @request = request
        @response = response
      end

      def request_parameters
        request.parameters
               .except(*request.path_parameters.keys.map(&:to_s))
               .except(*request.query_parameters.keys.map(&:to_s))
      end

      def request_identifier
        @desc
      end

      def response_headers
        @response_headers ||= filter_headers(response)
      end

      def request_headers
        @request_headers ||= filter_headers(request)
      end

      # Rails 4 includes the body params in the request_fullpath
      def request_fullpath
        if request.query_parameters.present?
          "#{request.path}?#{request_url_query_parameters}"
        else
          request.path
        end
      end

      private

      attr_reader :desc, :request, :response

      def filter_headers(obj)
        headers_whitelist.map do |header|
          header_val = obj.headers[header]
          next if header_val.blank?

          [header, header_val]
        end.compact
      end

      def headers_whitelist
        @headers_whitelist ||= Dox.full_headers_whitelist
      end

      def request_url_query_parameters
        CGI.unescape(request.query_parameters.to_query)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07039397450753186, 'fraction_numerical': 0.00028968713789107763, 'mean_word_length': 2.37866927592955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5909030', 'n_tokens_mistral': 974, 'n_tokens_neox': 955, 'n_words': 212}