Showing 18,390 of 18,390 total issues
Method menu_folders
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def menu_folders(view)
view.compact.map do |row|
row_id = nil
if @edit[:user_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
Method x_get_tree_server_roles
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def x_get_tree_server_roles
ServerRole.all.sort_by(&:description).each_with_object([]) do |r, objects|
next if @root.kind_of?(MiqRegion) && !r.regional_role? # Only regional roles under Region
next unless (@root.kind_of?(Zone) && r.miq_servers.any? { |s| s.my_zone == @root.name }) ||
(@root.kind_of?(MiqRegion) && !r.miq_servers.empty?) # Skip if no assigned servers in this zone
- 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 formOptions
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
var formOptions = function(vm) {
miqService.sparkleOn();
if (vm[vm.model].catalog_id !== undefined) {
allApiPromises.push(API.get('/api/service_catalogs/?expand=resources&attributes=id,name' + sortOptions)
.then(function(data) {
- Create a ticketCreate a ticket
Function add_flash
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.add_flash = function(msg, level, options) {
level = level || 'success';
options = options || {};
var cls = { alert: '', icon: '' };
- Create a ticketCreate a ticket
Function deleteNetwork
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const deleteNetwork = (row, data, setData, roles) => {
let dataTableData = data.dataTable.networkAdapters || [];
let submitNetworks = data.submitParams.networks.add || [];
let addNetworkIds = data.submitParams.networkIds.add || [];
const deleteNetworksData = data.submitParams.networks.delete || [];
- Create a ticketCreate a ticket
Method dialog_form_button_pressed
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dialog_form_button_pressed
case params[:button]
when "cancel"
return unless load_edit("dialog_edit__#{params[:id]}", "replace_cell__explorer")
- Create a ticketCreate a ticket
Method x_button
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def x_button
model, action = pressed2model_action(params[:pressed])
allowed_models = %w[common image instance vm miq_template provider automation storage infra_networking]
raise ActionController::RoutingError, 'Invalid button action' unless
allowed_models.include?(model)
- Create a ticketCreate a ticket
Method exp_commit_find
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def exp_commit_find(exp)
if @edit[@expkey][:exp_field].nil?
add_flash(_("A find field must be chosen to commit this expression element"), :error)
elsif %w[checkall checkany].include?(@edit[@expkey][:exp_check]) &&
@edit[@expkey][:exp_cfield].nil?
- Create a ticketCreate a ticket
Method buttons_get_node_info
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def buttons_get_node_info(node)
nodetype = node.split("_")
# initializing variables to hold data for selected node
@custom_button = nil
@sb[:button_groups] = nil
- Create a ticketCreate a ticket
Method cu_build_edit_screen
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cu_build_edit_screen
@edit = {}
@edit[:new] = {}
@edit[:current] = {}
@edit[:key] = "cu_edit__collection"
- Create a ticketCreate a ticket
Method action_field_changed
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def action_field_changed
return unless load_edit("miq_action_edit__#{params[:id]}")
@action = @edit[:action_id] ? MiqAction.find(@edit[:action_id]) : MiqAction.new
- Create a ticketCreate a ticket
Method provision_dialogs_update_create
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def provision_dialogs_update_create
case params[:button]
when "add", "save"
dialog = params[:id].blank? ? MiqDialog.new : MiqDialog.find(params[:id]) # Get new or existing record
if params[:name].blank?
- Create a ticketCreate a ticket
Method set_form_vars
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_form_vars
@edit[:new][:name] = @record.name
@edit[:new][:description] = @record.description
@edit[:new][:long_description] = @record.long_description
@edit[:new][:provision_cost] = @record.provision_cost
- Create a ticketCreate a ticket
Similar blocks of code found in 3 locations. Consider refactoring. Open
export const actionTypeData3 = {
title: _('Alerts to Evaluate'),
mode: 'miq_action_info',
message: _('No Alerts have been selected.'),
items: [
- 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 76.
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
it('should create an action to delete set tag', () => {
const tag = { tagCategory: 'cat', tagValue: 'val' };
const expectedAction = {
type: actionsConstants.DELETE_ASSIGNED_TAG,
tag,
- 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 76.
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
it('should create an action to add set tag', () => {
const tag = { tagCategory: 'cat', tagValue: 'val' };
const expectedAction = {
type: actionsConstants.CHANGE_ASSIGNED_TAGS,
tag,
- 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 76.
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
export const alertSetAlerts = {
title: __('Alerts'),
mode: 'miq_alert_set',
message: __('This Action is not assigned to any Policies.'),
items: [
- 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 76.
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
it('should create an action to toggle tag value change', () => {
const tag = { tagCategory: 'cat', tagValue: 'val' };
const expectedAction = {
type: actionsConstants.TOGGLE_TAG_VALUE_CHANGE,
tag,
- 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 76.
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
export const eventDefinitionPolicyData = {
title: _('Assigned to Policies'),
mode: 'miq_event_definition_policy',
message: _('This Event is not assigned to any Policies.'),
items: [
- 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 76.
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
<div className="col-xs-12 col-sm-12 col-md-12 col-lg-6 example-trend-container">
{processData.memory.dataAvailable
? (
<UtilizationMemoryDonutChart
data={data.metricsData}
- 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 76.
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