MayOneUS/mayday-2.0-backend

View on GitHub
lib/external_count_fetcher.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

  def fetch_supporter_counts(reset: false)
    if !@previously_called && !reset || (!redis_counter(:supporter_count).exists? || !redis_counter(:volunteer_count).exists?)
      Integration::NationBuilder.list_counts.each do |counter_key,count|
        redis_counter(counter_key).value = count
        redis_counter(counter_key).expire(REDIS_EXPIRE_SECONDS) if reset
Severity: Minor
Found in lib/external_count_fetcher.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 fetch_count has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def fetch_count(counter_key:, reset: false)
    if counter_key =~ /supporter_count|volunteer_count/
      fetch_supporter_counts
    else
      count = case counter_key
Severity: Minor
Found in lib/external_count_fetcher.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

There are no issues that match your filters.

Category
Status