schrodingersbox/split_cat

View on GitHub
app/models/split_cat/experiment.rb

Summary

Maintainability
A
3 hrs
Test Coverage

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 )
Severity: Minor
Found in app/models/split_cat/experiment.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 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 )
Severity: Minor
Found in app/models/split_cat/experiment.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

Avoid too many return statements within this method.
Open

      return hypothesis
Severity: Major
Found in app/models/split_cat/experiment.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return true if GoalSubject.find_by_goal_id_and_subject_id( goal.id, subject.id )
    Severity: Major
    Found in app/models/split_cat/experiment.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return true
      Severity: Major
      Found in app/models/split_cat/experiment.rb - About 30 mins to fix

        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
        
        
        Severity: Minor
        Found in app/models/split_cat/experiment.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