Showing 368 of 368 total issues
Method multi_destroy
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def multi_destroy
deleted = []
not_deleted = []
not_deleted_perms = []
- Read upRead up
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 load_events
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load_events
@source_type = params[:source_type].nil? ? "" : params[:source_type]
@pool_select = params[:pool_select].nil? ? "" : params[:pool_select]
@provider_select =
params[:provider_select].nil? ? "" : params[:provider_select]
File application_controller.rb
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'viewstate.rb'
require 'util/conductor'
require 'will_paginate/array'
class ApplicationController < ActionController::Base
Method index
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def index
clear_breadcrumbs
save_breadcrumb(pools_path(:viewstate => viewstate_id))
# This is primarily relevant to filter_view, but we check @details_tab in other places:
- Read upRead up
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 match_hardware_profile_property
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def self.match_hardware_profile_property(front_end_property, back_end_property)
# if the front_end_property is nil, we don't care about it, so everything matches:
return true if front_end_property.nil? || front_end_property.value.to_s.empty?
# if the back_end_property is nil, it only matches if front-end is also nil:
return false if back_end_property.nil? || back_end_property.value.to_s.empty?
- Read upRead up
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 update_quota
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def update_quota(state_from, state_to, an_instance)
pool = an_instance.pool
pool_family = pool.pool_family
user = an_instance.owner
provider_account = an_instance.provider_account
- Read upRead up
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 validate_hwp
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def validate_hwp
case name
when MEMORY
unless unit == UNIT_MB
errors.add(:unit, "Memory must be specified in MB")
- Read upRead up
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 transmit_event
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def transmit_event
# Extract just the old values from change_hash
old_values = {}
change_hash.each_pair do |k,v|
old_values[k] = v[0]
- Read upRead up
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
Class ProviderAccount
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class ProviderAccount < ActiveRecord::Base
class << self
include CommonFilterMethods
end
Identical blocks of code found in 2 locations. Consider refactoring. Open
def self.up
return if Role.all.empty?
Role.transaction do
role = Role.find_or_initialize_by_name(ROLE_NAME)
role.update_attributes({:name => ROLE_NAME, :scope => BasePermissionObject.name, :assign_to_owner => ROLE_DEF[0]})
- Read upRead up
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 114.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
def self.up
return if Role.all.empty?
Role.transaction do
role = Role.find_or_initialize_by_name(ROLE_NAME)
role.update_attributes({:name => ROLE_NAME, :scope => BasePermissionObject.name, :assign_to_owner => ROLE_DEF[0]})
- Read upRead up
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 114.
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
File views.js
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Open
Conductor.Views = Conductor.Views || {}
Conductor.Views.PoolsIndex = Backbone.View.extend({
el: '#content',
Method sortable_table_header
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def sortable_table_header(fields=[])
columns = fields.collect do |field|
if field[:sortable]==true or field[:sortable].nil?
order_dir = params[:order_dir] ? params[:order_dir] : 'desc'
if field[:sort_attr].to_s.eql?(params[:order_field])
- Read upRead up
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 _fast_gettext_old_format_m
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def _fast_gettext_old_format_m(args)
if args.kind_of?(Hash)
dup.gsub(INTERPOLATION_PATTERN_WITH_ESCAPE) do |match|
if match == '%%'
'%'
- Read upRead up
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 index
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
clear_breadcrumbs
save_breadcrumb(pools_path(:viewstate => viewstate_id))
# This is primarily relevant to filter_view, but we check @details_tab in other places:
File provider_account.rb
has 292 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ProviderAccount < ActiveRecord::Base
class << self
include CommonFilterMethods
end
File logs_controller.rb
has 289 lines of code (exceeds 250 allowed). Consider refactoring. Open
class LogsController < ApplicationController
before_filter :require_user
def index
clear_breadcrumbs
Method generate_graph
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def generate_graph
@group = params[:group].nil? ? "" : params[:group]
start_code = (@source_type == 'Deployment' ? 'first_running' : 'running')
end_code = (@source_type == 'Deployment' ? 'all_stopped' : 'stopped')
- Read upRead up
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_image_details
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def get_image_details
deployable_xml = DeployableXML.new(xml)
uuids = deployable_xml.image_uuids
images = []
missing_images = []
- Read upRead up
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 20 (exceeds 5 allowed). Consider refactoring. Open
def show
@pool = Pool.find(params[:id])
@title = @pool.name
save_breadcrumb(pool_path(@pool, :viewstate => viewstate_id), @pool.name)
require_privilege(Alberich::Privilege::VIEW, @pool)
- Read upRead up
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"