mtortonesi/symian

View on GitHub

Showing 20 of 20 total issues

Method initialize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(input)
      # allow filename, string, and IO objects as input
      if input.kind_of?(String)
        if File.exists?(input)
          input = File.new(input, 'r')
Severity: Minor
Found in lib/symian/transition_matrix.rb - About 3 hrs 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 run has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run

      # initialize support groups
      @support_groups.values.each do |sg|
        sg.initialize_at(@configuration.start_time)
Severity: Major
Found in lib/symian/simulation.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(type, params={})
          case type
            when :predefined
              # get workshift id
              raise ArgumentError unless params[:id]
    Severity: Minor
    Found in lib/symian/work_shift.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 merge has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def merge(sg1_name, sg2_name, new_name=nil)
          # raise error if support groups do not exist
          raise RuntimeError unless sg1_probs = @transition_probabilities.delete(sg1_name) and
                                    sg2_probs = @transition_probabilities.delete(sg2_name)
    
    
    Severity: Minor
    Found in lib/symian/transition_matrix.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 calculate_kpis has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def calculate_kpis(trace)
          raise ArgumentError, 'Argument must be a TraceCollector' unless TraceCollector === trace
    
          kpis = {}
    
    
    Severity: Minor
    Found in lib/symian/performance_analyzer.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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def run
    
          # initialize support groups
          @support_groups.values.each do |sg|
            sg.initialize_at(@configuration.start_time)
    Severity: Minor
    Found in lib/symian/simulation.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 secs_to_end_of_shift has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def secs_to_end_of_shift(time)
          raise 'secs_to_end_of_shift called for unavailable operator' unless active_at?(time)
          return Infinity if @type == :all_day_long
    
          t = time.utc.seconds_since_midnight.round
    Severity: Minor
    Found in lib/symian/work_shift.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 initialize has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(input)
          # allow filename, string, and IO objects as input
          if input.kind_of?(String)
            if File.exists?(input)
              input = File.new(input, 'r')
    Severity: Minor
    Found in lib/symian/transition_matrix.rb - About 1 hr to fix

      Method calculate_kpis has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def calculate_kpis(trace)
            raise ArgumentError, 'Argument must be a TraceCollector' unless TraceCollector === trace
      
            kpis = {}
      
      
      Severity: Minor
      Found in lib/symian/performance_analyzer.rb - About 1 hr to fix

        Method merge has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def merge(sg1_name, sg2_name, new_name=nil)
              # raise error if support groups do not exist
              raise RuntimeError unless sg1_probs = @transition_probabilities.delete(sg1_name) and
                                        sg2_probs = @transition_probabilities.delete(sg2_name)
        
        
        Severity: Minor
        Found in lib/symian/transition_matrix.rb - About 1 hr to fix

          Method try_to_allocate_operator has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def try_to_allocate_operator(time)
                  if !@available_operators.empty? and !@incident_queue.empty?
                    op = @available_operators.shift
                    i, inc_info, t = @incident_queue.shift
          
          
          Severity: Minor
          Found in lib/symian/support_group.rb - About 1 hr to fix

            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/symian/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 evaluate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def evaluate(kpis)
                  # evaluate operation costs
                  operations_cost = @configuration.support_groups.inject(0.0) do |sum,(sg_name,sg_conf)|
                    sg_costs = @configuration.cost_analysis[:operations].find{|sg| sg[:sg_name] == sg_name }
                    unless sg_costs
            Severity: Minor
            Found in lib/symian/cost_analyzer.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

            Method calculate_time_at_last_support_group has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def calculate_time_at_last_support_group(*types)
                    time = 0
                    last_sg = nil
                    @tracking_information.reverse_each do |ti|
                      last_sg ||= ti[:sg]
            Severity: Minor
            Found in lib/symian/incident.rb - About 45 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 secs_to_begin_of_shift has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def secs_to_begin_of_shift(time)
                  raise 'secs_to_begin_of_shift called for available operator' if active_at?(time)
            
                  t = time.utc.seconds_since_midnight.round
                  res = if @overnight
            Severity: Minor
            Found in lib/symian/work_shift.rb - About 45 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 calculate_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def calculate_time(type)
                    return 0 unless @tracking_information
                    @tracking_information.inject(0){|sum,x| sum += ((type == :all || type == x[:type]) ? x[:duration].to_i : 0) }
                  end
            Severity: Minor
            Found in lib/symian/incident.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

            Method assign has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def assign(incident, incident_info, time)
            
                  # initialize incident start work time if needed
                  incident.start_work_time ||= time
            
            
            Severity: Minor
            Found in lib/symian/operator.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

            Method to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_s
                  lines = [ "From/To,#{@sg_names.join(',')},Out" ]
                  [ "In", *@sg_names ].each do |input_sg|
                    escalations = [ @sg_names, "Out" ].flatten!.map do |output_sg|
                      @transition_probabilities[input_sg].map{|x| x[:sg_name] == output_sg ? x[:escalations] : nil }.compact.first || 0
            Severity: Minor
            Found in lib/symian/transition_matrix.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

            Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(oid, support_group_id, opts={})
                  @oid = oid
                  @support_group_id = support_group_id
            
                  # set correspondent instance variables for optional arguments
            Severity: Minor
            Found in lib/symian/operator.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

            Method try_to_allocate_operator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def try_to_allocate_operator(time)
                    if !@available_operators.empty? and !@incident_queue.empty?
                      op = @available_operators.shift
                      i, inc_info, t = @incident_queue.shift
            
            
            Severity: Minor
            Found in lib/symian/support_group.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