Showing 33 of 33 total issues
Method parse
has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring. Open
def self.parse(args, test_env = false)
@@quiet = test_env
options = Hashie::Mash.new
- 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 parse
has 255 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse(args, test_env = false)
@@quiet = test_env
options = Hashie::Mash.new
File occi_opts.rb
has 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'optparse'
require 'uri'
require 'erb'
# load all parts of OcciOpts
Method helper_describe
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def helper_describe(options, output = nil)
if resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) || options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
Occi::Cli::Log.debug "#{options.resource.inspect} is a resource type, type identifier or an actual resource."
resources_or_links = describe(options.resource)
- 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 helper_update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def helper_update(options, output = nil)
unless resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) \
|| \
options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
Occi::Cli::Log.error "I have no idea what #{options.resource.inspect} is ..."
- 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 helper_link_kind
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def helper_link_kind(options, link)
raise "No valid links given!" if link.blank?
case link
when /\/network\//, /\/ipreservation\//
- 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 helper_create_attach_context_vars
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def helper_create_attach_context_vars(options, res)
# TODO: find a better/universal way to do contextualization
return unless options.context_vars
Occi::Cli::Log.debug "with context variables: #{options.context_vars.inspect}"
Method resources_to_json
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def resources_to_json(occi_resources)
# generate JSON document from Occi::Core::Resources
occi_resources = occi_resources.to_a
if @output_format.to_s.end_with? '_pretty'
- 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 format
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def format(data)
# construct a method name from data type and output format
if data.kind_of? Occi::Core::Resources
method = "resources_to_#{@output_format}".to_sym
elsif data.kind_of? Occi::Core::Links
- 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 check_incompatible_args
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.check_incompatible_args(options, opts)
if !options.dump_model && options.filter
if @@quiet
exit false
else
- 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 helper_create_attach_links
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def helper_create_attach_links(options, res)
return unless options.links
Occi::Cli::Log.debug "with links: #{options.links.inspect}"
options.links.each do |link|
- 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 parse_context_variable
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_context_variable(cvar)
ary = CONTEXT_REGEXP.match(cvar).to_a.drop 1
raise ArgumentError, "Context variables must always contain ATTR=VALUE pairs!" unless ary.length == 2
symbol = ary[0].to_sym
- 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_mandatory_args
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.get_mandatory_args(options)
mandatory = []
if options.action == :trigger
mandatory << :trigger_action
- 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 helper_create_wait
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def helper_create_wait(resource_link, timeout)
begin
Timeout::timeout(timeout) {
Occi::Cli::Log.debug "Starting #{timeout}s wait period for #{resource_link.inspect} to become active"
while true
- 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 helper_trigger
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def helper_trigger(options, output = nil)
unless resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) \
|| \
options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
Occi::Cli::Log.error "I have no idea what #{options.resource.inspect} is ..."
- 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 helper_link
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def helper_link(options, output = nil)
location = nil
unless options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
raise "Given resource is not a valid instance URL! #{options.resource.inspect}"
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
unless resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) \
|| \
options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
Occi::Cli::Log.error "I have no idea what #{options.resource.inspect} is ..."
raise "Unknown resource #{options.resource.inspect}, there is nothing to trigger here!"
- 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 39.
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
unless resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) \
|| \
options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
Occi::Cli::Log.error "I have no idea what #{options.resource.inspect} is ..."
raise "Unknown resource #{options.resource.inspect}, there is nothing to update here!"
- 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 39.
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 helper_create_attach_mixins
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def helper_create_attach_mixins(options, res)
return unless options.mixins
Occi::Cli::Log.debug "with mixins: #{options.mixins.inspect}"
options.mixins.to_a.each do |mxn|
- 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 parse_attribute_value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_attribute_value(value)
result = value
ATTR_NUM_EXP =~ value
result = Regexp.last_match(:number).to_i if Regexp.last_match(:number)
- 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"