mtortonesi/sisfc

View on GitHub

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,_|
Severity: Minor
Found in lib/sisfc/simulation.rb - About 1 day to fix

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,_|
Severity: Major
Found in lib/sisfc/simulation.rb - About 7 hrs to fix

    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
    Severity: Minor
    Found in lib/sisfc/vm.rb - About 1 hr to fix

    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)
    Severity: Minor
    Found in lib/sisfc/sorted_array.rb - About 1 hr to fix

    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
    Severity: Minor
    Found in lib/sisfc/latency_manager.rb - About 55 mins to fix

    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
    Severity: Major
    Found in lib/sisfc/simulation.rb - About 45 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(vmid, dc_id, size, service_time_distribution, opts={})
      Severity: Minor
      Found in lib/sisfc/vm.rb - About 35 mins to fix

        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] }
        Severity: Minor
        Found in lib/sisfc/evaluation.rb - About 35 mins to fix

        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
        Severity: Minor
        Found in lib/sisfc/data_center.rb - About 35 mins to fix

        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')
        Severity: Minor
        Found in lib/sisfc/generator.rb - About 25 mins to fix

        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

        Severity
        Category
        Status
        Source
        Language