Updated

app/helpers / petition_helper.rb

A
36 lines of codes
6 methods
4.7 complexity/method
28 churn
28.17 complexity
0 duplications
module PetitionHelper
  1. PetitionHelper has no descriptive comment
def public_petition_facets_with_counts(petition_search) petition_search.facets.slice(*public_petition_facets) end def current_threshold(petition)
  1. PetitionHelper#current_threshold doesn't depend on instance state (maybe move it to another class?)
if petition.response_threshold_reached_at? || petition.government_response_at? Site.threshold_for_debate else Site.threshold_for_response end end def signatures_threshold_percentage(petition) threshold = current_threshold(petition).to_f percentage = petition.signature_count / threshold * 100 if percentage > 100 percentage = 100 elsif percentage < 1 percentage = 1 end number_to_percentage(percentage, precision: 2) end def petition_list_header @_petition_list_header ||= t(@petitions.scope, scope: :"petitions.list_headers", default: "") end def petition_list_header? petition_list_header.present? end def reveal_government_response? params[:reveal_response] == "yes" end end