File hardware_profiles_controller.rb
has 353 lines of code (exceeds 250 allowed). Consider refactoring. Open
class HardwareProfilesController < ApplicationController
before_filter :require_user
before_filter :load_hardware_profiles, :only => [:index, :show]
before_filter :setup_new_hardware_profile, :only => [:new]
before_filter :setup_hardware_profile, :only => [:new, :create, :matching_provider_hardware_profiles, :edit, :update]
Method update_cost
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_cost
redirect_to hardware_profiles_path unless params[:id]
@hardware_profile = HardwareProfile.find(params[:id])
require_privilege(Alberich::Privilege::MODIFY, @hardware_profile)
Method update_cost
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update_cost
redirect_to hardware_profiles_path unless params[:id]
@hardware_profile = HardwareProfile.find(params[:id])
require_privilege(Alberich::Privilege::MODIFY, @hardware_profile)
- 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 destroy
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def destroy
@hardware_profile = HardwareProfile.find(params[:id])
require_privilege(Alberich::Privilege::MODIFY, @hardware_profile)
if @hardware_profile.provider_hardware_profile?
Method show
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def show
@hardware_profile = HardwareProfile.find(Array(params[:id]).first)
require_privilege(Alberich::Privilege::VIEW, @hardware_profile)
@title = if @hardware_profile.provider_hardware_profile?
_('%s (Provider)') % @hardware_profile.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"
Further reading
Method load_hardware_profiles
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load_hardware_profiles
sort_order = sort_direction
sort_field = sort_column(HardwareProfile, 'name')
if sort_field == "name"
@hardware_profiles = HardwareProfile.where('provider_id IS NULL', {}).
Method multi_destroy
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def multi_destroy
deleted=[]
not_deleted=[]
HardwareProfile.find(params[:hardware_profile_selected]).each do |hwp|
- 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"