Showing 18,390 of 18,390 total issues
Cyclomatic complexity for get_reconfig_info is too high. [14/11] Open
def get_reconfig_info(reconfigure_ids)
@reconfigureitems = Vm.find(reconfigure_ids).sort_by(&:name)
# set memory to nil if multiple items were selected with different mem_cpu values
memory = @reconfigureitems.first.mem_cpu
memory = nil unless @reconfigureitems.all? { |vm| vm.mem_cpu == memory }
- 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
Cyclomatic complexity for handle_bottom_cell is too high. [14/11] Open
def handle_bottom_cell(presenter)
if allowed(@sb[:action]) && (@pages || @in_a_form)
if @pages
presenter.hide(:form_buttons_div)
elsif @in_a_form && @sb[:action]
- 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
Cyclomatic complexity for schedule_form_field_changed is too high. [14/11] Open
def schedule_form_field_changed
assert_privileges(@edit && @edit[:rpt_id] ? "miq_report_schedule_edit" : "miq_report_schedule_add")
return unless load_edit("schedule_edit__#{params[:id]}", "replace_cell__explorer")
schedule_get_form_vars
- 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
Cyclomatic complexity for center_toolbar_filename_explorer is too high. [14/11] Open
def center_toolbar_filename_explorer
if %w[vm_cloud vm_infra vm_or_template].include?(@layout)
center_toolbar_name_vm_or_template
elsif x_active_tree == :ae_tree
center_toolbar_filename_automate
- 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
Cyclomatic complexity for build_select_button is too high. [14/11] Open
def build_select_button(bgi, index)
bs_children = false
props = toolbar_button(bgi, :id => bgi[:id], :type => :buttonSelect)
return nil if props.nil?
- 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
Cyclomatic complexity for get_all_reps is too high. [14/11] Open
def get_all_reps(nodeid = nil)
# set nodeid from @sb, incase sort was pressed
nodeid = x_active_tree == :reports_tree ? x_node.split('-').last : x_node.split('-').last.split('_')[0] if nodeid.nil?
@sb[:miq_report_id] = nodeid
@record = @miq_report = MiqReport.for_user(current_user).find(@sb[:miq_report_id])
- 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
Cyclomatic complexity for tree_select is too high. [14/11] Open
def tree_select
assert_accordion_and_tree_privileges(x_active_tree)
params[:miq_grid_checks] = []
@explorer = true
@lastaction = "explorer"
- 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
Cyclomatic complexity for widget_form_field_changed is too high. [14/11] Open
def widget_form_field_changed
assert_privileges(feature_for_widget_action)
return unless load_edit("widget_edit__#{params[:id]}", "replace_cell__explorer")
widget_get_form_vars
- 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
Cyclomatic complexity for reconfigure_form_data is too high. [14/11] Open
def reconfigure_form_data(vm = @reconfigitems.first)
{
:recordId => @reconfigitems.collect(&:id),
:requestId => @request_id || 'new',
:roles => {
- 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
Function getInitialValues
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getInitialValues = (recId, setState) => {
if (recId) {
API.get(`/api/custom_buttons/${recId}?attributes=resource_action,uri_attributes`)
.then((initialValues) => {
if (initialValues.options.button_type === 'ansible_playbook') {
- Create a ticketCreate a ticket
Function setNetworkFormSubmit
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const setNetworkFormSubmit = (data, setData, formData, roles, renderData) => {
if (data.form.action === 'add') {
// code for add function
const id = `network${data.dataTable.networkAdapters.length}`;
const networkData = {
- Create a ticketCreate a ticket
Function render
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
// eslint-disable-next-line consistent-return
const renderSpinner = (spinnerOn) => {
if (spinnerOn) {
return (
- Create a ticketCreate a ticket
Function onClick
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
const onClick = (button) => {
let buttonUrl;
if (button.confirm && !window.confirm(button.confirm)) {
// No handling unless confirmed.
- Create a ticketCreate a ticket
Method layout_uses_listnav?
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def layout_uses_listnav?
return false if action_name == "show"
return false if show_list_with_no_provider?
return false if show_list_ansible?
- Create a ticketCreate a ticket
Method catalog_basic_information
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def catalog_basic_information(record, sb_params, tenants_tree)
prov_types = catalog_provision_types
prov_data = [prov_types[:template], prov_types[:ovf]].include?(record.prov_type) && (catalog_provision?(record, :playbook) || catalog_provision?(record, :terraform_template)) ? provisioning : nil
data = {:title => _('Basic Information'), :mode => "miq_catalog_basic_information"}
rows = []
- Create a ticketCreate a ticket
Method launch_external_logging
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def launch_external_logging
assert_privileges('ems_container_launch_external_logging')
record = self.class.model.find(params[:id])
ems = record.ext_management_system
route_name = ems.external_logging_route_name
- Create a ticketCreate a ticket
Method view_to_hash
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def view_to_hash(view, fetch_data = false)
root = {:head => [], :rows => []}
has_checkbox = !@embedded && !@no_checkboxes
- Create a ticketCreate a ticket
Method db_get_node_info
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def db_get_node_info
model, rec_id, _ = TreeBuilder.extract_node_model_and_id(x_node)
@sb[:nodes] = x_node.split('-')
if @sb[:nodes].length == 1
@default_ws = MiqWidgetSet.where_unique_on("default").where(:read_only => true).first
- Create a ticketCreate a ticket
Similar blocks of code found in 3 locations. Consider refactoring. Open
MiqStructuredListConditionalTag.propTypes = {
row: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.any), PropTypes.shape({})]).isRequired,
clickEvents: PropTypes.bool.isRequired,
onClick: PropTypes.func,
};
- 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 75.
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 3 locations. Consider refactoring. Open
MiqStructuredListBodyValue.propTypes = {
row: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.any), PropTypes.shape({})]).isRequired,
clickEvents: PropTypes.bool.isRequired,
onClick: PropTypes.func,
};
- 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 75.
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