crowbar/crowbar-core

View on GitHub
crowbar_framework/app/controllers/ucs_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

File ucs_controller.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "net/http"
require "uri"
require "rexml/document"
require "cgi"

Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 3 hrs to fix

Class UcsController has 23 methods (exceeds 20 allowed). Consider refactoring.
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"

Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 2 hrs to fix

Method aaaLogin has 48 lines of code (exceeds 25 allowed). Consider refactoring.
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
Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 1 hr to fix

Method aaaLogin has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
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
Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 1 hr to fix

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

  def update
    @updateDoc = ""

    case params[:updateAction]
    when "compute"
Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 1 hr to fix

Method instantiate_service_profile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
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|
Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 1 hr to fix

Avoid too many return statements within this method.
Open

      return nil
Severity: Major
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

      return nil
Severity: Major
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

      return nil
Severity: Major
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

      return nil
Severity: Major
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

    return ucs_cookie
Severity: Major
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 30 mins to fix

Method edit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def edit
    # N.B. the ls:Server class (in which 'ls' stands for
    # logical server) encapsulates:
    #
    #   - service profiles
Severity: Minor
Found in crowbar_framework/app/controllers/ucs_controller.rb - About 25 mins to fix

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

There are no issues that match your filters.

Category
Status