Showing 135 of 135 total issues
File build_vapp.rb
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'securerandom'
require 'etc'
require 'netaddr'
module VagrantPlugins
- Create a ticketCreate a ticket
File base.rb
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'log4r'
require 'vagrant/util/busy'
require 'vagrant/util/platform'
require 'vagrant/util/retryable'
require 'vagrant/util/subprocess'
- Create a ticketCreate a ticket
Method call
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
@env = env
cfg = env[:machine].provider_config
cnx = cfg.vcloud_cnx.driver
- Create a ticketCreate a ticket
Method get_edge_gateway_rules
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_edge_gateway_rules(edge_gateway_name, vdc_id)
edge_gateway_id = find_edge_gateway_id(edge_gateway_name, vdc_id)
params = {
'method' => :get,
- Create a ticketCreate a ticket
Method send_request
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def send_request(params, payload = nil, content_type = nil)
# Create a new HTTP client
clnt = HTTPClient.new
# Set SSL proto to TLSv1
- 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 remove_edge_gateway_rules
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def remove_edge_gateway_rules(edge_gateway_name, vdc_id, edge_gateway_ip, vapp_id)
edge_vapp_ip = get_vapp_edge_public_ip(vapp_id)
edge_gateway_id = find_edge_gateway_id(edge_gateway_name, vdc_id)
params = {
- Create a ticketCreate a ticket
Method get_vapp_port_forwarding_rules
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_vapp_port_forwarding_rules(vapp_id, network_name=nil)
params = {
'method' => :get,
'command' => "/vApp/vapp-#{vapp_id}/networkConfigSection"
}
- Create a ticketCreate a ticket
Method get_vapp_port_forwarding_rules
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_vapp_port_forwarding_rules(vapp_id, network_name=nil)
params = {
'method' => :get,
'command' => "/vApp/vapp-#{vapp_id}/networkConfigSection"
}
- 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 compile_forwarded_ports
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def compile_forwarded_ports(machine)
mappings = {}
machine.config.vm.networks.each do |type, options|
if type == :forwarded_port
- Create a ticketCreate a ticket
Method get_organization
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_organization(org_id)
params = {
'method' => :get,
'command' => "/org/#{org_id}"
}
- Create a ticketCreate a ticket
Method set_vapp_port_forwarding_rules
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_vapp_port_forwarding_rules(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 get_vm
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_vm(vm_id)
params = {
'method' => :get,
'command' => "/vApp/vm-#{vm_id}"
}
- Create a ticketCreate a ticket
Method get_vapp_edge_public_ip
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_vapp_edge_public_ip(vapp_id, network_name=nil)
return @cached_vapp_edge_public_ips["#{vapp_id}#{network_name}"] unless @cached_vapp_edge_public_ips["#{vapp_id}#{network_name}"].nil?
# Check the network configuration section
params = {
- Create a ticketCreate a ticket
Method vcloud_upload_box
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def vcloud_upload_box(env)
cfg = env[:machine].provider_config
cnx = cfg.vcloud_cnx.driver
box_dir = env[:machine].box.directory.to_s
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
module VCloud
module Action
class PowerOff
def initialize(app, env)
@app = app
- 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 60.
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
module VCloud
module Action
class ShutDown
def initialize(app, env)
@app = app
- 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 60.
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 get_vapp
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_vapp(vapp_id)
params = {
'method' => :get,
'command' => "/vApp/vapp-#{vapp_id}"
}
- Create a ticketCreate a ticket
Method find_edge_gateway_network
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_edge_gateway_network(edge_gateway_name, vdc_id, edge_gateway_ip)
params = {
'method' => :get,
'command' => '/query?type=edgeGateway&' \
'format=records&' \
- Create a ticketCreate a ticket
Method set_metadata
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_metadata(link, data)
params = {
'method' => :post,
'command' => "/#{link}/metadata"
}
- Create a ticketCreate a ticket
Method call
has 32 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
- Create a ticketCreate a ticket