lib/aptimizer/pomdpx/transitionbuilder.rb
Method build_public_argument_transitions
has a Cognitive Complexity of 228 (exceeds 5 allowed). Consider refactoring. Open
Open
def build_public_argument_transitions(xml, agent, opponent, modification_hash)
public_or_atks = lambda {|p| p[0].type == :pub || p[0].type == :atk}
modification_hash.lazy.select(&public_or_atks).each do |pred, modif_arrays|
if modif_arrays[1].empty? && !modif_arrays[0].empty? # No modification of the predicate by the opponent
build_agent_side_transitions(xml, agent, pred, modif_arrays[0])
- 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 build_public_argument_transitions
has 132 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def build_public_argument_transitions(xml, agent, opponent, modification_hash)
public_or_atks = lambda {|p| p[0].type == :pub || p[0].type == :atk}
modification_hash.lazy.select(&public_or_atks).each do |pred, modif_arrays|
if modif_arrays[1].empty? && !modif_arrays[0].empty? # No modification of the predicate by the opponent
build_agent_side_transitions(xml, agent, pred, modif_arrays[0])
Method build_agent_side_transitions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
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))
- 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"