schrodingersbox/split_cat

View on GitHub

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

Severity: Minor
Found in lib/split_cat/random.rb - About 1 hr to fix

    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

          Severity
          Category
          Status
          Source
          Language