app/controllers/pages_controller.rb
Class PagesController
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class PagesController < ApplicationController # rubocop:disable Metrics/ClassLength
newrelic_ignore_enduser only: %i[show follow_up double_opt_in_notice]
skip_before_action :verify_authenticity_token, raise: false, only: %i[create update destroy]
before_action :authenticate_user!, except: %i[feeds show follow_up double_opt_in_notice]
before_action :get_page, only: %i[edit update destroy follow_up double_opt_in_notice analytics actions preview emails]
Method show
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def show
respond_to :html
one_click_processor = process_one_click
Method redirect_to_donations_experiment
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def redirect_to_donations_experiment
return unless @page.published?
return unless @page.language_code
return unless @page.donation_page?
return if user_signed_in?
- 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"