File admins_controller.rb
has 399 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'delayed/command'
class AdminsController < ApplicationController
include CommonSweepers
Method edit_tag
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def edit_tag
if request.post?
@tag=TextValue.find(params[:id])
replacement_tags = []
- 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"
Further reading
Class AdminsController
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class AdminsController < ApplicationController
include CommonSweepers
RESTART_MSG = "Your settings have been updated. If you changed some settings e.g. search, you need to restart some processes.
Please see the buttons and explanations below."
Method get_stats
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_stats
collection = []
type = nil
title = nil
@page=params[:id]
Method update_others
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def update_others
update_flag = true
if Seek::Config.tag_threshold.to_s != params[:tag_threshold] || Seek::Config.max_visible_tags.to_s!=params[:max_visible_tags]
expire_annotation_fragments
end
- 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"
Further reading
Method edit_tag
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def edit_tag
if request.post?
@tag=TextValue.find(params[:id])
replacement_tags = []
Method update_features_enabled
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_features_enabled
Seek::Config.public_seek_enabled= string_to_boolean(params[:public_seek_enabled] || true)
Seek::Config.events_enabled= string_to_boolean params[:events_enabled]
Seek::Config.jerm_enabled= string_to_boolean params[:jerm_enabled]
Seek::Config.email_enabled= string_to_boolean params[:email_enabled]
Method restart_delayed_job
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def restart_delayed_job
error = nil
if Rails.env!="test"
begin
Seek::Workers.restart
- 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"
Further reading
Method test_email_configuration
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def test_email_configuration
smtp_hash_old = ActionMailer::Base.smtp_settings
smtp_hash_new = {:address => params[:address], :enable_starttls_auto => params[:enable_starttls_auto]=="1", :domain => params[:domain], :authentication => params[:authentication], :user_name => (params[:user_name].blank? ? nil : params[:user_name]), :password => (params[:password].blank? ? nil : params[:password])}
smtp_hash_new[:port] = params[:port] if only_integer params[:port], 'port'
ActionMailer::Base.smtp_settings = smtp_hash_new
- 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"