Showing 10 of 10 total issues
Method evaluate_allocation
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
def evaluate_allocation(vm_allocation)
# TODO: allow to define which feasibility controls to run in simulation
# configuration. Here we hardcode a simple feasibility check: fail unless
# there is at least one vm for each software component.
@configuration.service_component_types.each do |sc_id,_|
- 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 evaluate_allocation
has 193 lines of code (exceeds 25 allowed). Consider refactoring. Open
def evaluate_allocation(vm_allocation)
# TODO: allow to define which feasibility controls to run in simulation
# configuration. Here we hardcode a simple feasibility check: fail unless
# there is at least one vm for each software component.
@configuration.service_component_types.each do |sc_id,_|
Method new_request
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def new_request(sim, r, time)
# put request w/ metadata at the end of the queue
@request_queue << RequestInfo.new(r, @service_times_rv.next, time)
if @trace
- 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 insert
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def insert(i, v)
if size == 0 or v < self[0]
super(0, v)
elsif v > self[-1]
super(-1, v)
- 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 sample_latency_between
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def sample_latency_between(loc1, loc2)
if loc1 == loc2
# rejection sampling to implement (crudely) PDF truncation
while (lat = @same_location_latency.next) < 2E-3; end
lat
- 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
Avoid deeply nested control flow statements. Open
if new_vm
# need to update data_center_id of request
req.data_center_id = dc.dcid
# keep track of transmission time
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(vmid, dc_id, size, service_time_distribution, opts={})
Method evaluate_business_impact
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def evaluate_business_impact(all_kpis, per_workflow_and_customer_kpis,
vm_allocation)
# evaluate variable hourly costs related to VM allocation
cost = vm_allocation.inject(0.0) do |s,x|
hc = @vm_hourly_cost.find{|i| i[:data_center] == x[:dc_id] and i[:vm_type] == x[:vm_size] }
- 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 add_vm
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_vm(vm, component_name)
@vms[component_name] ||= []
@vm_type_count[vm.size] ||= 0
raise 'Error! VM is already present!' if @vms[component_name].include? vm
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(opts = {})
if opts.key? :filename
raise ArgumentError, "File #{opts[:filename]} does not exist!" unless File.exist?(opts[:filename])
@file = File.open(opts[:filename], 'r')
- 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"