EHadoux/aptimizer

View on GitHub
lib/aptimizer/pomdpx/xmlhelpers.rb

Summary

Maintainability
C
1 day
Test Coverage

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

      def evaluate_goal_compliance(goals_hash)
        atk_arr, pred_arr = goals_hash.partition{|p| p[0].type == :atk}
        value_hash        = Hash.new
        pred_arr.each do |pred, value|
          return false if pred.positive && !value
Severity: Minor
Found in lib/aptimizer/pomdpx/xmlhelpers.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_goal_compliance_dr has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def evaluate_goal_compliance_dr(goals_hash, agent, public_space)
        atk_arr, pred_arr = goals_hash.partition{|p| !agent.goals.include? p[0]}
        value_hash        = Hash.new
        pred_arr.each do |pred, value|
          return false if pred.positive && !value
Severity: Minor
Found in lib/aptimizer/pomdpx/xmlhelpers.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 get_goal_full_set has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def get_goal_full_set(agent, public_space)
        set      = Set.new
        arg_set  = Set.new
        set.merge(agent.goals)
        arg_set.merge(agent.goals)
Severity: Minor
Found in lib/aptimizer/pomdpx/xmlhelpers.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 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 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 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

    There are no issues that match your filters.

    Category
    Status