Class MiqRequestController
has 41 methods (exceeds 20 allowed). Consider refactoring. Open
class MiqRequestController < ApplicationController
include Mixins::GenericSessionMixin
include Mixins::BreadcrumbsMixin
before_action :check_privileges, :except => :post_install_callback
- Create a ticketCreate a ticket
File miq_request_controller.rb
has 524 lines of code (exceeds 400 allowed). Consider refactoring. Open
class MiqRequestController < ApplicationController
include Mixins::GenericSessionMixin
include Mixins::BreadcrumbsMixin
before_action :check_privileges, :except => :post_install_callback
- Create a ticketCreate a ticket
Method prov_continue
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def prov_continue
assert_privileges("miq_request_edit")
if params[:button] == "continue" # Continue the request from the workflow with the new options
id = params[:id] || "new"
return unless load_edit("prov_edit__#{id}", "show_list")
- 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 stamp
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def stamp
assert_privileges(rbac_feature_id("miq_request_approval"))
if params[:button] == "cancel"
if (session[:edit] && session[:edit][:stamp_typ]) == "a"
flash_to_session(_("Request approval was cancelled by the user"))
- 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
Cyclomatic complexity for prov_continue is too high. [12/11] Open
def prov_continue
assert_privileges("miq_request_edit")
if params[:button] == "continue" # Continue the request from the workflow with the new options
id = params[:id] || "new"
return unless load_edit("prov_edit__#{id}", "show_list")
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
Method show_list
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def show_list
@breadcrumbs = []
bc_name = _("Requests")
@request_tab = params[:typ] if params[:typ] # set this to be used to identify which Requests subtab was clicked
@layout = layout_from_tab_name(@request_tab)
- 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 stamp
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stamp
assert_privileges(rbac_feature_id("miq_request_approval"))
if params[:button] == "cancel"
if (session[:edit] && session[:edit][:stamp_typ]) == "a"
flash_to_session(_("Request approval was cancelled by the user"))
- Create a ticketCreate a ticket
Method show_list
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show_list
@breadcrumbs = []
bc_name = _("Requests")
@request_tab = params[:typ] if params[:typ] # set this to be used to identify which Requests subtab was clicked
@layout = layout_from_tab_name(@request_tab)
- Create a ticketCreate a ticket
Method prov_continue
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prov_continue
assert_privileges("miq_request_edit")
if params[:button] == "continue" # Continue the request from the workflow with the new options
id = params[:id] || "new"
return unless load_edit("prov_edit__#{id}", "show_list")
- Create a ticketCreate a ticket
Method prov_copy
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prov_copy
assert_privileges("miq_request_copy")
org_req = MiqRequest.where(:id => params[:req_id].to_i).first
req = MiqRequest.new(
:approval_state => 'pending_approval',
- Create a ticketCreate a ticket
Method report_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def report_data
super
if params[:model_name] == "MiqRequest"
@request_filters = {}
params[:additional_options][:named_scope].each do |option|
- 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 prov_scope
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def prov_scope(opts)
scope = []
# Request date (created since X days ago)
scope << [:created_recently, opts[:time_period].to_i] if opts[:time_period].present?
# Select requester user across regions
- 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 deleterequests
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def deleterequests
assert_privileges(rbac_feature_id("miq_request_delete"))
miq_requests = find_records_with_rbac(MiqRequest, checked_or_params)
if miq_requests.empty?
- 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 show
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show
identify_request
return if record_no_longer_exists?(@miq_request)
@display = params[:display] || "main" unless pagination_or_gtl_request?
- 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 retrieve_email
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def retrieve_email
assert_privileges("miq_request_edit")
@edit = session[:edit]
begin
method = WORKFLOW_METHOD_WHITELIST[params[:field]]
- 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 request_edit
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def request_edit
assert_privileges(rbac_feature_id("miq_request_edit"))
provision_request = MiqRequest.find(params[:id])
if provision_request.workflow_class || provision_request.kind_of?(MiqProvisionConfiguredSystemRequest)
request_edit_settings(provision_request)
- 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"