Showing 6 of 6 total issues
Class Legislator
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Legislator < ActiveRecord::Base
belongs_to :district
belongs_to :state
has_many :targets
has_many :campaigns, through: :targets
Class Person
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Person < ActiveRecord::Base
has_one :subscription
has_one :location, dependent: :destroy
has_one :district, through: :location
has_one :representative, through: :district
Method merge_duplicates!
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.merge_duplicates!(records, compare_on:)
records.each do |record|
next if record.nil?
records.each do |other|
next if other.nil?
- Read upRead up
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 all_reps_with_us
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.all_reps_with_us
response = JSON.parse(RestClient.get(bills_url))
reps = []
if bills = response[BILLS_KEY]
bills.each do |bill|
- Read upRead up
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_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
- Read upRead up
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
- Read upRead up
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"