Showing 11 of 11 total issues
Method user_vote
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.user_vote(post)
VotePost.transaction do
if post.vote_option_ids.present?
post.trim_votecode
post.selected = post.vote_option_ids.length
- 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 split_votecode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def split_votecode(value)
if value.is_a?(Array) && value.size == 2
((value.first.nil? ? t('log.missing') : value.first.to_s) + t('log.to') +
(value.last.nil? ? t('log.missing') : value.last.to_s))
else
- 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 split_hash
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def split_hash(key, value, model)
val = ''
val = case key
when 'user_id'
split_array(value)
Method attends
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.attends(user)
add_user_error(user, 'attend_no_item') if SubItem.current.nil?
return false if user.errors[:base].any?
User.transaction do
user.update!(presence: 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 option_details
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def option_details
return unless vote_option_ids.present?
unless vote_option_ids.count <= vote.choices
errors.add(:vote_option_ids, I18n.t('model.vote_post.too_many_options'))
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 set_card_number
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.set_card_number(user, card_number)
if user.present? && card_number.present?
if user.persisted? && user.card_number.present?
user.errors.add(:card_number, I18n.t('model.user.card_number_already_set'))
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 unattends
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.unattends(user)
add_user_error(user, 'unattend_vote_current') if Vote.current.present?
add_user_error(user, 'unattend_no_item') if SubItem.current.nil?
return false if user.errors[:base].any?
User.transaction do
- 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 inline_css
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def inline_css(asset_path)
if %w[development test].include?(Rails.env.to_s)
file = Rails.application.assets.find_asset(asset_path)
file.source if file.present?
else
- 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 user_vote_header
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def user_vote_header(vote)
if vote.present?
content_tag(:div, class: 'headline') do
content_tag(:h2) do
state = vote.open? ? t('vote.open') : t('vote.close')
- 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 admin_print_user
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def admin_print_user(user)
return unless user.present?
content = []
content << fa_icon('times') unless user.confirmed?
content << fa_icon('credit-card') << ' ' if user.card_number.present?
- 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 current_child_to?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def current_child_to?(parent)
agenda = Agenda.now
return unless agenda.present?
while agenda.parent.present?
- 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"