Showing 135 of 135 total issues
Method call
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
config = env[:machine].provider_config
if !config.vcloud_cnx or !config.vcloud_cnx.driver.auth_key
@logger.info('Connecting to vCloud Director...')
- Create a ticketCreate a ticket
Method action_ssh
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.action_ssh
Vagrant::Action::Builder.new.tap do |b|
# b.use ConfigValidate
b.use Call, IsCreated do |env, b2|
unless env[:result]
- 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
def get_catalog_item(catalog_item_id)
params = {
'method' => :get,
'command' => "/catalogItem/#{catalog_item_id}"
}
- 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 54.
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
def get_catalog(catalog_id)
params = {
'method' => :get,
'command' => "/catalog/#{catalog_id}"
}
- 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 54.
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 add_vapp_port_forwarding_rules
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_vapp_port_forwarding_rules(vapp_id, network_name, edge_network_name, config = {})
params = {
'method' => :get,
'command' => "/vApp/vapp-#{vapp_id}/networkConfigSection"
}
- Create a ticketCreate a ticket
Method call
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
cfg = env[:machine].provider_config
cnx = cfg.vcloud_cnx.driver
vapp_id = env[:machine].get_vapp_id
vm_name = cfg.name ? cfg.name.to_sym : env[:machine].name
- Create a ticketCreate a ticket
Identical blocks of code found in 2 locations. Consider refactoring. Open
if nic[:ip_mode].upcase == 'DHCP'
conn['vcloud:ipAddressingMode'] = 'DHCP'
elsif nic[:ip_mode].upcase == 'STATIC'
conn['vcloud:ipAddressingMode'] = 'MANUAL'
conn['vcloud:ipAddress'] = nic[:ip]
- 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 53.
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
if nic[:ip_mode].upcase == 'DHCP'
conn['vcloud:ipAddressingMode'] = 'DHCP'
elsif nic[:ip_mode].upcase == 'STATIC'
conn['vcloud:ipAddressingMode'] = 'MANUAL'
conn['vcloud:ipAddress'] = nic[:ip]
- 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 53.
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 set_ovf_properties
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_ovf_properties(vm_id, properties)
params = {
'method' => :get,
'command' => "/vApp/vm-#{vm_id}/productSections"
}
- Create a ticketCreate a ticket
Method create_vapp_from_template
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_template_id, poweron = false)
builder = Nokogiri::XML::Builder.new do |xml|
xml.InstantiateVAppTemplateParams(
'xmlns' => 'http://www.vmware.com/vcloud/v1.5',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
- Create a ticketCreate a ticket
Method action_destroy
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.action_destroy
Vagrant::Action::Builder.new.tap do |b|
b.use Call, DestroyConfirm do |env, b2|
if env[:result]
b2.use ConfigValidate
- Create a ticketCreate a ticket
Method get_catalog_id_by_name
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_catalog_id_by_name(organization, catalog_name)
result = nil
organization[:catalogs].each do |catalog|
if catalog[0].downcase == catalog_name.downcase
- Create a ticketCreate a ticket
Method set_vm_network_config
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_vm_network_config(vm_id, network_name, config = {})
builder = Nokogiri::XML::Builder.new do |xml|
xml.NetworkConnectionSection(
'xmlns' => 'http://www.vmware.com/vcloud/v1.5',
'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1') {
- Create a ticketCreate a ticket
Method upload_ovf
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def upload_ovf(vdc_id, vapp_name, vapp_description, ovf_file, catalog_id, upload_options = {})
# if send_manifest is not set, setting it true
if upload_options[:send_manifest].nil? ||
upload_options[:send_manifest]
upload_manifest = 'true'
- 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_vdc
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_vdc(vdc_id)
params = {
'method' => :get,
'command' => "/vdc/#{vdc_id}"
}
- Create a ticketCreate a ticket
Method set_vapp_network_config
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_vapp_network_config(vapp_id, network_name, config = {})
builder = Nokogiri::XML::Builder.new do |xml|
xml.NetworkConfigSection(
'xmlns' => 'http://www.vmware.com/vcloud/v1.5',
'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1'
- Create a ticketCreate a ticket
Method read_state
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_state(env)
# FIXME: this part needs some cleanup
begin
cfg = env[:machine].provider_config
cnx = cfg.vcloud_cnx.driver
- Create a ticketCreate a ticket
Method set_vm_network_connected
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_vm_network_connected(vm_id)
params = {
'method' => :get,
'command' => "/vApp/vm-#{vm_id}/networkConnectionSection"
}
- Create a ticketCreate a ticket
Similar blocks of code found in 4 locations. Consider refactoring. Open
def poweroff_vm(vm_id)
builder = Nokogiri::XML::Builder.new do |xml|
xml.UndeployVAppParams(
'xmlns' => 'http://www.vmware.com/vcloud/v1.5'
) { xml.UndeployPowerAction 'powerOff' }
- 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 47.
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 4 locations. Consider refactoring. Open
def suspend_vm(vm_id)
builder = Nokogiri::XML::Builder.new do |xml|
xml.UndeployVAppParams(
'xmlns' => 'http://www.vmware.com/vcloud/v1.5'
) { xml.UndeployPowerAction 'suspend' }
- 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 47.
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