EHadoux/aptimizer

View on GitHub

Showing 30 of 30 total issues

Method is_true_dr? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def is_true_dr?(predicate, atk_arr, value_hash, public_space, stack)
        return value_hash[predicate] if value_hash.include?(predicate)
        atk_arr.lazy.select{|atk| public_space.backup_attacks.include?(Predicate.new(:atk, atk[0].argument1, arg2:predicate.argument1)) && stack.none?{|p| atk[0].argument1 != p.argument1}}.each do |atk|
          next unless atk[1]
          stack.unshift atk[0]
Severity: Minor
Found in lib/aptimizer/pomdpx/xmlhelpers.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 is_true? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def is_true?(predicate, atk_arr, value_hash, stack)
        return value_hash[predicate] if value_hash.include?(predicate)
        atk_arr.lazy.select{|atk| (atk[0].argument2 == predicate.argument1) && stack.none?{|p| atk[0].argument1 != p.argument1 && atk[0].argument2 != p.argument2}}.each do |atk|
          next unless atk[1]
          stack.unshift atk[0]
Severity: Minor
Found in lib/aptimizer/pomdpx/xmlhelpers.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 remove_irrelevant_args has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def remove_irrelevant_args(aps, verbose)
      if verbose
        puts "\n--> Applying irrelevant arguments optimization:"
      end
      remove = ->(set, num="") do
Severity: Minor
Found in lib/aptimizer/objects/optimizer.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 optimize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def optimize(aps, verbose=true, cycle=true, optimizations=[])
      aps if optimizations.include?(:none)
      flags_list = [:irrelevant, :initial, :enthymeme, :dominated]
      (f = (optimizations - flags_list)) and (raise "Unknown flags :#{f} Known flags are #{flags_list}" unless f.empty?)
      optimizations = flags_list if optimizations.empty?
Severity: Minor
Found in lib/aptimizer/objects/optimizer.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 is? has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def is?(type, arg1, arg2=nil, positive=true, owner=1)
Severity: Minor
Found in lib/aptimizer/objects/predicate.rb - About 35 mins to fix

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

        def initialize(arguments, rules, initial_state, goals=[[],[]], action_names=nil)
    Severity: Minor
    Found in lib/aptimizer/objects/agent.rb - About 35 mins to fix

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

            def is_true_dr?(predicate, atk_arr, value_hash, public_space, stack)
      Severity: Minor
      Found in lib/aptimizer/pomdpx/xmlhelpers.rb - About 35 mins to fix

        Method build_agent_side_transitions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def build_agent_side_transitions(xml, agent, predicate, modifying_actions)
                  prem_set = Set.new
                  prem_set.add(predicate.unsided)
                  modifying_actions.each do |act_i, _|
                    prem_set.merge(agent.actions[act_i].premises.map(&:unsided))
        Severity: Minor
        Found in lib/aptimizer/pomdpx/transitionbuilder.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 compatible? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def compatible?(rule, instance, prem_arr)
                premisses = []
                prem_arr.drop(1).each_with_index do |prem, prem_i|
                  next unless rule.premises.map(&:unsided).include?(prem)
                  if instance[prem_i+2] == "s0"
        Severity: Minor
        Found in lib/aptimizer/pomdpx/xmlhelpers.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 build_cond_prob has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_cond_prob(xml, var, parent, *instances)
                xml.CondProb {
                  xml.Var var
                  xml.Parent parent
                  xml.Parameter(:type => "TBL") {
        Severity: Minor
        Found in lib/aptimizer/pomdpx/xmlhelpers.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