Showing 84 of 154 total issues
Method officials_by_state_and_office
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def officials_by_state_and_office(state_id, office_ids)
office_ids.each_with_index do |office_id, index|
begin
state_id = state_id == 'us' ? 'NA' : state_id.upcase
return get('Officials.getByOfficeState',
- 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 perform
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def perform(id)
question = Question.find(id)
user = question.user
if user && question.coordinates.blank?
- 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 office_ids
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def office_ids(options)
# Chairman, Councilmember
return [347, 368] if options[:state] == 'dc'
office_ids = []
- 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
Consider simplifying this complex logical expression. Open
return session if session_details[session].key?("type") && session_details[session]["type"] == type ||
type == "primary" && !session_details[session]["display_name"][/Budget|Called|Extraordinary|Fiscal|Special/] ||
type == "special" && session_details[session]["display_name"][/Budget|Called|Extraordinary|Fiscal|Special/]
Consider simplifying this complex logical expression. Open
if (width.blank? || height.blank?) ||
(opts[:state] && opts[:state] == Metadatum::Unaffiliated::ABBREVIATION) ||
api_key.blank? ||
Rails.env.development?
Method find_site_key_and_video_id
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find_site_key_and_video_id
VIDEO_SITE_URL_PATTERNS.each do |key, value|
value.each do |pattern|
if original_url =~ pattern
key = :youtube_full if key == :youtube
- 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 new
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def new
new! do
if params[:twitter_id]
screen_name = params[:twitter_id]
twitter_api = TwitterPersonService.new(screen_name, false)
- 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 most_recent_session
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def most_recent_session(type)
session_details = read_attribute(:session_details)
read_attribute(:terms).last["sessions"].reverse.each do |session|
# OpenStates doesn't always declare the session type.
return session if session_details[session].key?("type") && session_details[session]["type"] == type ||
- 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 state_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def state_name
if state? || federal?
@jurisdiction['name']
elsif local?
state = Metadatum.where(abbreviation: state_abbreviation).first
- 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 legacy_skip_for_now
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def legacy_skip_for_now(office, division)
(office.level == "county" && (office.name.downcase != "mayor" &&
!office.name.downcase.include?("council"))) ||
(office.level == "federal" && division.scope == "national") ||
((office.level == "city" || office.level == "other") &&
- 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 perform
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def perform(id)
self.person = Person.find(id.to_s)
return unless person.photo_url.present?
unless ImageLinkChecker.new(person.photo_url).accessible?
- 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
Avoid too many return
statements within this function. Open
return options.messages.even;
Avoid too many return
statements within this function. Open
return options.message;
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return options.messages.odd;
Avoid too many return
statements within this function. Open
return options.messages[check];
Method id
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def id
raise "Must specify state" unless state
raise "Only municipality or county, not both" if municipality && county
id = state.downcase
- 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 new
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def new
set_up_steps
@question = Question.new(state: @state_code)
@question.user = user_signed_in? ? current_user : User.new
@question.user.for_new_question = true
- 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 copy_to_new_person
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def copy_to_new_person
unless Metadatum.where(id: state).first
copy_to_new_metadatum
end
- 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 guess_office_level
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def guess_office_level(office, division)
if office.is_governor? || office.is_state_legislator?
GoogleCivicInfo::Office::STATE
elsif office.is_federal_legislator? || office.is_federal_executive_or_judicial?
GoogleCivicInfo::Office::FEDERAL
- 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"