app/controllers/smart_proxies_controller.rb
Class SmartProxiesController
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class SmartProxiesController < ApplicationController
include Foreman::Controller::AutoCompleteSearch
include Foreman::Controller::Parameters::SmartProxy
before_action :find_resource, :only => [:show, :edit, :update, :refresh, :ping, :tftp_server, :destroy, :log_pane, :failed_modules, :errors_card, :modules_card, :expire_logs]
Method expire_logs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def expire_logs
from = (params[:from].to_i rescue 0) || 0
if from >= 0
logger.debug "Expired smart-proxy logs, new timestamp is #{from}"
@smart_proxy.expired_logs = from.to_s
- 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 refresh
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def refresh
old_features = @smart_proxy.feature_details
if @smart_proxy.refresh.blank? && @smart_proxy.save
msg = (@smart_proxy.reload.feature_details == old_features) ? _("No changes found when refreshing features from %s.") : _("Successfully refreshed features from %s.")
process_success :object => @smart_proxy, :success_msg => msg % @smart_proxy.name
- 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"