goyalmunish/request_response_stats

View on GitHub
lib/generators/templates/req_res_stat_controller.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

      There are no issues that match your filters.

      Category
      Status