Updated

app/helpers / application_helper.rb

B
64 lines of codes
10 methods
6.4 complexity/method
14 churn
64.14 complexity
0 duplications
require 'uri' module ApplicationHelper
  1. ApplicationHelper has no descriptive comment
INDEXED_PAGES = [ %w[pages index], %w[pages help], %w[pages privacy], %w[local_petitions index], %w[local_petitions show], %w[petitions index], %w[petitions show], %w[petitions new], %w[archived/petitions index], %w[archived/petitions show] ] def increment(amount = 1) @counter ||= 0 @counter += amount end def home_page? params.values_at(:controller, :action) == %w[pages index] end def create_petition_page? params[:controller] == 'petitions' && params[:action].in?(%w[check create new]) end def petition_page? params.values_at(:controller, :action) == %w[petitions show] end def open_petition_page? petition_page? && @petition.open? end def archived_petition_page? params[:controller] == 'archived/petitions' && params[:action] == 'show' end def back_url referer_url || 'javascript:history.back()' end def noindex_page? !params.values_at(:controller, :action).in?(INDEXED_PAGES) end def original_url request.original_url.force_encoding('utf-8') end private def referer_url
  1. ApplicationHelper#referer_url has approx 6 statements
begin uri = URI.parse(request.referer)
  1. ApplicationHelper#referer_url calls 'request.referer' 2 times Locations: 0 1
%i[scheme host port].all?{ |k| uri.send(k) == request.send(k) } ? request.referer : nil
  1. ApplicationHelper#referer_url calls 'request.referer' 2 times Locations: 0 1
  2. ApplicationHelper#referer_url has the variable name 'k'
rescue URI::InvalidURIError => e
  1. ApplicationHelper#referer_url has the variable name 'e'
nil end end end