code-mancers/rapidfire

View on GitHub

Showing 6 of 11 total issues

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

    def validate_answer(answer)
      if rules[:presence] == "1"
        case self
        when Rapidfire::Questions::File
          if Rails::VERSION::MAJOR >= 6
Severity: Minor
Found in app/models/rapidfire/question.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 save! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def save!(options = {})
      params.each do |question_id, answer_attributes|
        answer = @attempt.answers.find { |a| a.question_id.to_s == question_id.to_s }
        next unless answer

Severity: Minor
Found in app/services/rapidfire/attempt_builder.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 validate_answer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def validate_answer(answer)
      if rules[:presence] == "1"
        case self
        when Rapidfire::Questions::File
          if Rails::VERSION::MAJOR >= 6
Severity: Minor
Found in app/models/rapidfire/question.rb - About 1 hr to fix

    Method filter_link has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def filter_link(question_id, option)
          question_id = question_id.to_s
          option = option.to_s
    
          this_filter = {
    Severity: Minor
    Found in app/helpers/rapidfire/application_helper.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 validate_answer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_answer(answer)
            super(answer)
    
            if rules[:presence] == "1" || answer.answer_text.present?
              answer.answer_text.to_s.split(Rapidfire.answers_delimiter).each do |value|
    Severity: Minor
    Found in app/models/rapidfire/questions/checkbox.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

    Method validate_answer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_answer(answer)
            super(answer)
    
            if rules[:presence] == "1" || answer.answer_text.present?
              gt_or_lt = {}
    Severity: Minor
    Found in app/models/rapidfire/questions/numeric.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