Showing 18,390 of 18,390 total issues
Method prov_set_form_vars
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
def prov_set_form_vars(req = nil)
@edit ||= {}
session[:prov_options] = @options = nil # Clearing out options that were set on show screen
@edit[:req_id] = req.try(:id) # Save existing request record id, if passed in
@edit[:key] = "prov_edit__#{@edit[:req_id] || "new"}"
- 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 fields_get_form_vars
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
def fields_get_form_vars
@ae_class = MiqAeClass.find_by(:id => @edit[:ae_class_id])
@in_a_form = true
@in_a_form_fields = true
if params[:item].blank? && !%w[accept save].include?(params[:button]) && params["action"] != "field_delete"
- 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 form_method_field_changed
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
def form_method_field_changed
assert_privileges(feature_by_action)
return unless load_edit("aemethod_edit__#{params[:id]}", "replace_cell__explorer")
get_method_form_vars
- 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 get_view
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
def get_view(db, options = {}, fetch_data = false)
if !fetch_data && @report_data_additional_options.nil?
process_show_list_options(options, db)
end
if @in_a_form && @edit.present?
- 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 button
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
def button
@edit = session[:edit] # Restore @edit for adv search box
params[:display] = @display if %w[all_vms vms hosts resource_pools].include?(@display) # Were we displaying sub-items
if params[:pressed].starts_with?("vm_", # Handle buttons from sub-items screen
- 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
File schedules.rb
has 694 lines of code (exceeds 400 allowed). Consider refactoring. Open
module OpsController::Settings::Schedules
extend ActiveSupport::Concern
# Show the main Schedules list view
def schedules_list
- Create a ticketCreate a ticket
File diagnostics.rb
has 689 lines of code (exceeds 400 allowed). Consider refactoring. Open
module OpsController::Diagnostics
extend ActiveSupport::Concern
def diagnostics_tree_select
assert_privileges("ops_diagnostics")
- Create a ticketCreate a ticket
Cyclomatic complexity for replace_right_cell is too high. [73/11] Open
def replace_right_cell(options = {})
action, replace_trees, presenter = options.values_at(:action, :replace_trees, :presenter)
@explorer = true
# FIXME: make this functional
- 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
File filter.rb
has 675 lines of code (exceeds 400 allowed). Consider refactoring. Open
module ApplicationController::Filter
extend ActiveSupport::Concern
include ::MiqExpression::SubstMixin
include ApplicationController::ExpressionHtml
included do
- Create a ticketCreate a ticket
Method replace_right_cell
has 213 lines of code (exceeds 25 allowed). Consider refactoring. Open
def replace_right_cell(options = {})
@explorer = true
action = options[:action]
replace_trees = options[:replace_trees] || []
get_node_info unless @in_a_form
- Create a ticketCreate a ticket
Method button
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def button
@edit = session[:edit] # Restore @edit for adv search box
params[:display] = @display if %w[vms storages].include?(@display) # Were we displaying vms/storages
if params[:pressed].starts_with?("vm_", # Handle buttons from sub-items screen
- 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 53 (exceeds 5 allowed). Consider refactoring. Open
def show
assert_privileges("dashboard_view")
@layout = "dashboard"
@display = "dashboard"
@lastaction = "show"
- 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 schedule_get_form_vars
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def schedule_get_form_vars
@schedule = @edit[:sched_id] ? MiqSchedule.find(@edit[:sched_id]) : MiqSchedule.new(:userid => session[:userid])
copy_params_if_present(@edit[:new], params, %i[name description])
@edit[:new][:enabled] = (params[:enabled] == "1") if params[:enabled]
@edit[:new][:filter] = params[:filter_typ] if params[:filter_typ]
- 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
File analysis_profiles.rb
has 657 lines of code (exceeds 400 allowed). Consider refactoring. Open
module OpsController::Settings::AnalysisProfiles
extend ActiveSupport::Concern
CATEGORY_CHOICES = {
"system" => N_("System"),
- Create a ticketCreate a ticket
Method view_to_url
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def view_to_url(view, parent = nil)
association = view_to_association(view, parent)
if association.nil?
controller, action = db_to_controller(view.db)
if controller == "ems_cloud" && action == "show"
- 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 alert_build_edit_screen
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def alert_build_edit_screen
@edit = {}
@edit[:new] = {}
@edit[:current] = {}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
"ManageIQ::Providers::AnsibleTower::AutomationManager::MachineCredential": {
"label": "Machine",
"type": "machine",
"attributes": {
"userid": {
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 195.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
"ManageIQ::Providers::Awx::AutomationManager::MachineCredential": {
"label": "Machine",
"type": "machine",
"attributes": {
"userid": {
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 195.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method center_toolbar_filename_classic
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
def center_toolbar_filename_classic
# Original non vmx view code follows
# toolbar buttons on sub-screens
to_display = %w[availability_zones cloud_networks cloud_object_store_containers cloud_subnets configured_systems
cloud_tenants cloud_volumes cloud_volume_snapshots ems_clusters flavors floating_ips host_aggregates hosts host_initiators host_initiator_groups
- 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 atomic_form_field_changed
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
def atomic_form_field_changed
assert_privileges(session&.fetch_path(:edit, :rec_id) ? "atomic_catalogitem_edit" : "atomic_catalogitem_new")
# need to check req_id in session since we are using common code for prov requests and atomic ST screens
id = session[:edit][:req_id] || "new"
- 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"