crowbar_framework/app/controllers/ucs_controller.rb
File ucs_controller.rb
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require "net/http"
require "uri"
require "rexml/document"
require "cgi"
- Create a ticketCreate a ticket
Class UcsController
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class UcsController < ApplicationController
CREDENTIALS_XML_PATH = "/etc/crowbar/cisco-ucs/credentials.xml"
COMPUTE_SERVICE_PROFILE = "suse-cloud-compute"
STORAGE_SERVICE_PROFILE = "suse-cloud-storage"
- Create a ticketCreate a ticket
Method aaaLogin
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def aaaLogin(ucs_url, username, password)
if ucs_url.blank?
logger.debug "Cisco UCS: missing login URL"
redirect_to ucs_settings_path, alert: "You must provide a login URL"
return nil
- Create a ticketCreate a ticket
Method aaaLogin
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def aaaLogin(ucs_url, username, password)
if ucs_url.blank?
logger.debug "Cisco UCS: missing login URL"
redirect_to ucs_settings_path, alert: "You must provide a login URL"
return nil
- Read upRead up
- Create a ticketCreate a ticket
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 update
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def update
@updateDoc = ""
case params[:updateAction]
when "compute"
- Create a ticketCreate a ticket
Method instantiate_service_profile
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def instantiate_service_profile(action)
logger.debug "Cisco UCS: will instantiate from #{action} template"
match_count = 0
get_class_instances("computePhysical").each do |element|
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
Open
return ucs_cookie
- Create a ticketCreate a ticket
Method edit
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def edit
# N.B. the ls:Server class (in which 'ls' stands for
# logical server) encapsulates:
#
# - service profiles
- Read upRead up
- Create a ticketCreate a ticket
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"