CartoDB/cartodb20

View on GitHub
lib/cartodb/stats/api_calls.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method get_api_calls_from_redis has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def get_api_calls_from_redis(username, options = {})
        calls = {}

        REDIS_SOURCES.each do |source|
          source_calls = get_api_calls_from_redis_source(username, source, options)
Severity: Minor
Found in lib/cartodb/stats/api_calls.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_api_calls_from_redis_source has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def get_api_calls_from_redis_source(username, api_call_type, options = {})
        redis_key = redis_api_call_key(username, api_call_type, options[:stat_tag])
        date_to = (options[:to] ? options[:to].to_date : Date.today)
        date_from = (options[:from] ? options[:from].to_date : date_to - 29.days)

Severity: Minor
Found in lib/cartodb/stats/api_calls.rb - About 1 hr to fix

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

          def get_api_calls_from_redis_source(username, api_call_type, options = {})
            redis_key = redis_api_call_key(username, api_call_type, options[:stat_tag])
            date_to = (options[:to] ? options[:to].to_date : Date.today)
            date_from = (options[:from] ? options[:from].to_date : date_to - 29.days)
    
    
    Severity: Minor
    Found in lib/cartodb/stats/api_calls.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_api_calls_without_dates has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def get_api_calls_without_dates(username, options = {})
            calls = get_api_calls(username, options).map {|day, value| value}
            if options[:old_api_calls]
              raise "Cannot request old api calls with custom dates" if options[:to] or options[:from]
              # Add old api calls
    Severity: Minor
    Found in lib/cartodb/stats/api_calls.rb - About 55 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