Showing 18,382 of 18,382 total issues
Method set_form_vars
has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring. Open
def set_form_vars
@edit = {}
@edit[:rpt_id] = @rpt.id # Save a record id to use it later to look a record
@edit[:rpt_title] = @rpt.title
@edit[:rpt_name] = @rpt.name
- 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_valid_record?
has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring. Open
def alert_valid_record?(alert)
if alert.expression.nil?
add_flash(_("A valid expression must be present"), :error)
end
unless display_driving_event?
- 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
Function createSchema
has 245 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createSchema = (state, setState, ems, initialValues, storageId, setStorageId) => {
let emsId = state.ems_id;
if (initialValues && initialValues.ems_id) {
emsId = initialValues.ems_id;
}
- Create a ticketCreate a ticket
Method perf_gen_charts
has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring. Open
def perf_gen_charts(rpt, perf_options, parent = false)
model_title = parent ? "Parent-#{perf_options[:parent]}" : perf_options[:model]
charts = []
chart_data = []
case perf_options[: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
Function addSchema
has 237 lines of code (exceeds 25 allowed). Consider refactoring. Open
const addSchema = (formValues) => {
const basicOptions = generateBasicOptions();
const rangeNine = generateRange(10);
const rangeFour = generateRange(5);
const rangeFive = generateRange(6);
- Create a ticketCreate a ticket
Method workflow_instance_from_vars
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
def workflow_instance_from_vars(req)
options = {}
pre_prov_values = nil
if %w[miq_template service_template vm].include?(@edit[:org_controller])
if params[:prov_type] && !req # only do this new requests
- 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
it('should call methods - singleValue is true', () => {
const onTagCategoryChange = jest.fn();
const onTagValueChange = jest.fn();
const onSingleTagValueChange = jest.fn();
const onTagDeleteClick = jest.fn();
- 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 222.
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
it('should call methods - singleValue is false', () => {
const onTagCategoryChange = jest.fn();
const onTagValueChange = jest.fn();
const onSingleTagValueChange = jest.fn();
const onTagDeleteClick = jest.fn();
- 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 222.
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 show
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
def show(id = nil)
@flash_array = [] if params[:display] && params[:display] != "snapshot_info"
@sb[:action] = params[:display]
return if perfmenu_click?
- 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 diagnostics_set_form_vars
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
def diagnostics_set_form_vars
active_node = x_node
if active_node && active_node.split('-').first == "z"
@record = @selected_server = Zone.find_by(:id => active_node.split('-').last)
@sb[:selected_server_id] = @selected_server.id
- 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 set_global_session_data
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
def set_global_session_data
@sb ||= {}
# Set all of the global variables used by most of the controllers
session[:layout] = @layout
session[:panels] = @panels
- 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_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 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 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 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
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