goyalmunish/request_response_stats

View on GitHub

Showing 15 of 15 total issues

Method capture_request_response_cycle_end_info has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def capture_request_response_cycle_end_info(capture_error: false)
      return gather_stats unless gather_stats

      # get system info
      current_time = get_system_current_time
Severity: Major
Found in lib/request_response_stats/request_response.rb - About 2 hrs to fix

    Class RedisRecord has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class RedisRecord
        attr_accessor :key, :value
    
        REDIS_RR_KEY_NAMESPACE = "api_req_res"
    
    
    Severity: Minor
    Found in lib/request_response_stats/redis_record.rb - About 2 hrs to fix

      Method get_details has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get_details(key, start_time, end_time, stat_type = nil, granularity = DEFAULT_STATS_GRANULARITY)
            # get ungrouped data
            stat_type = stat_type.to_s.to_sym if stat_type
            key = key.to_s.to_sym
            relevant_records = get_within(start_time, end_time)
      Severity: Minor
      Found in lib/request_response_stats/req_res_stat.rb - About 1 hr to fix

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

            def log_request_response_stats(name, args, &original_call)
              if defined?(RR_OUTBOUND_STATS) && RR_OUTBOUND_STATS
                begin
                  uri = args.is_a?(Array) ? args.first : args
                  uri = uri[custom_uri_key] if (uri.is_a?(Hash) && custom_uri_key && uri[custom_uri_key])
        Severity: Minor
        Found in lib/request_response_stats/custom_client.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_request_response_stats has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                def log_request_response_stats
                  if defined?(RR_INBOUND_STATS) && RR_INBOUND_STATS
                    begin
                      rrs = RequestResponse.new(request, response, {redis_connection: $redis, gather_stats: true, mongoid_doc_model: ReqResStat})
                      rrs.capture_request_response_cycle_start_info
        Severity: Minor
        Found in lib/request_response_stats/controller_concern.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 fetch_stats_for has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def fetch_stats_for(stat_key, start_time, end_time, granularity_in_hours, base_records=nil)
            if base_records
              # use the passed basic dataset
              base_req_res_stats = base_records
            else
        Severity: Minor
        Found in lib/generators/templates/req_res_stat_controller.rb - About 1 hr to fix

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

            def get_stats
              # query conditions
              start_time = params[:start_time].present? ? parase_data_time_zone(params[:start_time]) : Time.now - 7.days
              end_time = params[:end_time].present? ? parase_data_time_zone(params[:end_time]) : Time.now
              granularity_in_hours = params[:granularity_in_hours].present? ? params[:granularity_in_hours].to_i.hours : 1.hour
          Severity: Minor
          Found in lib/generators/templates/req_res_stat_controller.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 capture_request_response_cycle_start_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def capture_request_response_cycle_start_info
                return gather_stats unless gather_stats
          
                # get system info
                current_time = get_system_current_time
          Severity: Minor
          Found in lib/request_response_stats/request_response.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 get_system_memory_info_mb has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_system_memory_info_mb
                key_name = redis_record.support_key(get_server_hostname, [get_server_hostname, "memory"].join("_"))
                value = ActiveSupport::HashWithIndifferentAccess.new(redis_record.parsed_get key_name)
                return_value = if value == {}
                  mem_info = (`free -ml`).split(" ") rescue []
          Severity: Minor
          Found in lib/request_response_stats/request_response.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 get_details has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_details(key, start_time, end_time, stat_type = nil, granularity = DEFAULT_STATS_GRANULARITY)
                # get ungrouped data
                stat_type = stat_type.to_s.to_sym if stat_type
                key = key.to_s.to_sym
                relevant_records = get_within(start_time, end_time)
          Severity: Minor
          Found in lib/request_response_stats/req_res_stat.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 fetch_stats_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def fetch_stats_for(stat_key, start_time, end_time, granularity_in_hours, base_records=nil)
          Severity: Minor
          Found in lib/generators/templates/req_res_stat_controller.rb - About 35 mins to fix

            Method get_stat has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def get_stat(stat_type, key, start_time, end_time, granularity = DEFAULT_STATS_GRANULARITY)
            Severity: Minor
            Found in lib/request_response_stats/req_res_stat.rb - About 35 mins to fix

              Method get_details has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def get_details(key, start_time, end_time, stat_type = nil, granularity = DEFAULT_STATS_GRANULARITY)
              Severity: Minor
              Found in lib/request_response_stats/req_res_stat.rb - About 35 mins to fix

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

                    def move_data_from_redis_to_mongo(at_once=true)
                      if at_once
                        # multiple records will be inserted to mongodb at once
                        # this is to minimize the index creation time
                        values = []
                Severity: Minor
                Found in lib/request_response_stats/request_response.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 capture_request_response_cycle_end_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def capture_request_response_cycle_end_info(capture_error: false)
                      return gather_stats unless gather_stats
                
                      # get system info
                      current_time = get_system_current_time
                Severity: Minor
                Found in lib/request_response_stats/request_response.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