Showing 7 of 7 total issues
Method generate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.generate( args )
n_subjects = args[ :n_subjects ].to_i
n_experiments = args[ :n_experiments ].to_i
max_items = args[ :max_items ].to_i
Method record_goal
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def record_goal( goal, token )
return true if winner_id
return false unless goal = goal_hash[ goal ]
return false unless subject = Subject.find_by_token( token )
- 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 get_hypothesis
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_hypothesis( token )
return winner if winner.present?
return nil unless subject = Subject.find_by_token( token )
if join = HypothesisSubject.find_by_experiment_id_and_subject_id( id, subject.id )
- 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
Avoid too many return
statements within this method. Open
return hypothesis
Avoid too many return
statements within this method. Open
return true if GoalSubject.find_by_goal_id_and_subject_id( goal.id, subject.id )
Avoid too many return
statements within this method. Open
return true
Method factory
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.factory( name )
if experiment = @@cache[ name ]
return experiment
end
- 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"