Updated

app/helpers / debate_outcome_helper.rb

A
25 lines of codes
3 methods
6.9 complexity/method
2 churn
20.69 complexity
0 duplications
require 'ostruct' module DebateOutcomeHelper
  1. DebateOutcomeHelper has no descriptive comment
DEBATE_OUTCOME_URLS = %i[video_url transcript_url debate_pack_url] def debate_outcome_image(debate_outcome) sources = ['1x', '2x'].map { |size| "#{debate_outcome.commons_image.url(size)} #{size}" }
  1. DebateOutcomeHelper#debate_outcome_image calls 'debate_outcome.commons_image' 2 times Locations: 0 1
  2. DebateOutcomeHelper#debate_outcome_image refers to 'debate_outcome' more than self (maybe move it to another class?) Locations: 0 1
image_tag(debate_outcome.commons_image.url('2x'), 'aria-hidden': '', srcset: sources.join(', '))
  1. DebateOutcomeHelper#debate_outcome_image calls 'debate_outcome.commons_image' 2 times Locations: 0 1
  2. DebateOutcomeHelper#debate_outcome_image refers to 'debate_outcome' more than self (maybe move it to another class?) Locations: 0 1
end def debate_outcome_links?(debate_outcome)
  1. DebateOutcomeHelper#debate_outcome_links? doesn't depend on instance state (maybe move it to another class?)
DEBATE_OUTCOME_URLS.any? { |url| debate_outcome.public_send(:"#{url}?") } end def debate_outcome_links(debate_outcome)
  1. DebateOutcomeHelper#debate_outcome_links doesn't depend on instance state (maybe move it to another class?)
DEBATE_OUTCOME_URLS.map do |url| if debate_outcome.public_send(:"#{url}?") OpenStruct.new( title: I18n.t(url, scope: :"petitions.debate_outcomes.link_titles"), url: debate_outcome.public_send(:"#{url}") ) end end.compact end end