Showing 84 of 154 total issues
Method show
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_navigational_format?
- 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
Method new_with_session
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.new_with_session(params, session)
super.tap do |user|
data = session['devise.facebook_data']
if data
user.email = data['info']['email'] if user.email.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
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 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
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 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 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 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 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
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return options.message;
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.even;
Avoid too many return
statements within this function. Open
return options.messages[check];
Method district_or_office_for
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def district_or_office_for(person)
district_or_office = person['district']
# reset if federal
if person.state == 'us'
- 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 jurisdiction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def jurisdiction(object)
if @jurisdiction
@jurisdiction
else
@jurisdictions ||= {}
- 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 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 jurisdiction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def jurisdiction
return jurisdiction_from_scope if legacy?
jurisdiction = state
if division.is_county?
- 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"