Method index
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def index
authenticate_user! unless params[:token]
if subscriber
@subscriptions = subscriber.subscriptions
Method selected_comment_ids
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def selected_comment_ids
comment_ids = []
update_params[ :spam_comments ].each_pair do |key, value|
next unless value == '1'
Method add_element
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def add_element( formatting, name )
return add_long_text_element name if formatting == 'simple_format'
return add_html_element name if formatting == 'sanitize'
return add_image_element name if formatting == 'image_tag' || name.include?( 'image' )
Method check_with_akismet
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def check_with_akismet
return true if user_signed_in?
return true unless akismet_api_key_is_set? && feature_enabled?( :akismet_for_comments )
spam, blatant = akismet_check( request, @new_comment )
Avoid too many return
statements within this method.
return false unless user.admin?
Method perform
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def perform( send )
return unless send.sendable?
send.mark_as_sending
Method update_value
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def update_value( id, params )
setting = Setting.find( id )
return false if setting.level == 'site'
return false if setting.level == 'admin' && current_user_is_not_admin?
Method seed_setting
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def seed_setting( name:, value: '', description: nil, level: 'site', locked: false )
setting = ShinyCMS::Setting.find_or_create_by!( name: name.to_s )
setting.unlock
setting.update!( description: description ) if description.present?
Method enabled?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def self.enabled?( name, user = nil )
feature = find_by( name: name.to_s )
return false if feature.blank?
return true if feature.enabled?