Showing 38 of 38 total issues
Method get_vdc
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_vdc(vdc_id)
vdc_id = vdc_id.to_i
response = Excon::Response.new
vdc = self.data[:organizations].map { |org| org[:vdcs] }.flatten.find { |vdc| vdc[:id] == vdc_id }
Method mock_data
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.mock_data
{
:organizations =>
[
{
Method instantiate_vapp_template
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def instantiate_vapp_template(name, vapp_template, options = {})
raise ArgumentError.new("Name must be fewer than 15 characters") unless name.length < 15
raise ArgumentError.new("vApp Image Template is a compulsary parameter") unless vapp_template
options["ssh_key_fingerprint"] ||= default_ssh_key["FingerPrint"]
options["cpus"] ||= 1
Method configure_vapp
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def configure_vapp(vapp_id, vapp_name, options = {})
items = ""
vapp_uri = [@host, @path, "vApp", vapp_id.to_s].join("/")
if options["vcpus"]
Method start_element
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def start_element(name, attributes)
super
case name
when "Link"
link = extract_attributes(attributes)
- 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 end_element
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def end_element(name)
case name
when "Description", "Protocol"
@internet_service[name] = value
when "Enabled"
- 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_network
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_network(network_id)
network_id = network_id.to_i
response = Excon::Response.new
network = self.data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.find { |network| network[:id] == network_id }
if network
Method instantiate_vapp_template
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def instantiate_vapp_template(name, vapp_template, options = {})
raise ArgumentError.new("Name must be fewer than 15 characters") unless name.length < 15
raise ArgumentError.new("vApp Image Template is a compulsary parameter") unless vapp_template
options["ssh_key_fingerprint"] ||= default_ssh_key["FingerPrint"]
options["cpus"] ||= 1
- 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_public_ips
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_public_ips(vdc_id)
vdc_id = vdc_id.to_i
response = Excon::Response.new
vdc = self.data[:organizations].map { |org| org[:vdcs] }.flatten.find { |vdc| vdc[:id] == vdc_id }
Method end_element
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def end_element(name)
case name
when "Description", "Protocol"
@internet_service[name] = value
when "Enabled"
Method create_internet_services
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_internet_services(internet_spec)
public_ip_info = nil
internet_service_id = nil
internet_spec.each do |proto, ports|
for port in ports
Method end_element
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def end_element(name)
case name
when "IpAddress"
@response["IpAddress"] = value
when "Description"
Method end_element
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def end_element(name)
case name
when "Description", "Protocol"
@response[name] = value
when "Enabled"
- 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 start_element
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_element(name, attributes)
super
case name
when "Cpu"
@in_cpu = true
Method end_element
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def end_element(name)
case name
when "Allocated", "Limit", "Units", "Used"
if @in_cpu
@response["ComputeCapacity"]["Cpu"][name] = value
Method save
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save
requires :Name, :Protocol, :Port
if !public_ip_address_id
#Create the first internet service and allocate public IP
data = service.create_internet_service(
Method start_element
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_element(name, attributes)
super
case name
when "Link"
link = extract_attributes(attributes)
Method end_element
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def end_element(name)
case name
when "Description", "Protocol"
@response[name] = value
when "Enabled"
Method end_element
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def end_element(name)
case name
when "IpAddress"
@response["IpAddress"] = value
when "Description"
- 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 create_internet_service
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_internet_service(vdc_id, name, protocol, port, options = {})