expertiza/expertiza

View on GitHub
app/models/cake.rb

Summary

Maintainability
A
3 hrs
Test Coverage
A
90%

Assignment Branch Condition size for edit is too high. [67.36/15]
Open

  def edit(_count)
    html = '<td align="center"><a rel="nofollow" data-method="delete" href="/questions/' + id.to_s + '">Remove</a></td>'
    html += '<td><input size="6" value="' + seq.to_s + '" name="question[' + id.to_s + '][seq]"'
    html += ' id="question_' + id.to_s + '_seq" type="text"></td>'
    html += '<td><textarea cols="50" rows="1" name="question[' + id.to_s + '][txt]"'
Severity: Minor
Found in app/models/cake.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for complete is too high. [56.03/15]
Open

  def complete(count, answer = nil, total_score)
    if size.nil?
      cols = '70'
      rows = '1'
    else
Severity: Minor
Found in app/models/cake.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [29/10]
Open

  def complete(count, answer = nil, total_score)
    if size.nil?
      cols = '70'
      rows = '1'
    else
Severity: Minor
Found in app/models/cake.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for view_question_text is too high. [24.35/15]
Open

  def view_question_text
    html = '<TD align="left"> ' + txt + ' </TD>'
    html += '<TD align="left">' + type + '</TD>'
    html += '<td align="center">' + weight.to_s + '</TD>'
    questionnaire = self.questionnaire
Severity: Minor
Found in app/models/cake.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for view_completed_question is too high. [20.69/15]
Open

  def view_completed_question(count, answer)
    score = answer && !answer.answer.nil? ? answer.answer.to_s : '-'
    html = '<b>' + count.to_s + '. ' + txt + '</b>'
    html += '<div class="c5" style="width:30px; height:30px;' \
      ' border-radius:50%; font-size:15px; color:black; line-height:30px; text-align:center;">'
Severity: Minor
Found in app/models/cake.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [12/10]
Open

  def edit(_count)
    html = '<td align="center"><a rel="nofollow" data-method="delete" href="/questions/' + id.to_s + '">Remove</a></td>'
    html += '<td><input size="6" value="' + seq.to_s + '" name="question[' + id.to_s + '][seq]"'
    html += ' id="question_' + id.to_s + '_seq" type="text"></td>'
    html += '<td><textarea cols="50" rows="1" name="question[' + id.to_s + '][txt]"'
Severity: Minor
Found in app/models/cake.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method complete has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def complete(count, answer = nil, total_score)
    if size.nil?
      cols = '70'
      rows = '1'
    else
Severity: Minor
Found in app/models/cake.rb - About 1 hr to fix

    Method get_total_score_for_questions has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def self.get_total_score_for_questions(review_type, questions, participant_id, assignment_id, reviewee_id)
    Severity: Minor
    Found in app/models/cake.rb - About 35 mins to fix

      Method get_total_score_for_question has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def get_total_score_for_question(review_type, question_id, participant_id, assignment_id, reviewee_id)
      Severity: Minor
      Found in app/models/cake.rb - About 35 mins to fix

        Method get_answers_for_teammatereview has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def get_answers_for_teammatereview(team_id, question_id, participant_id, assignment_id, reviewee_id)
        Severity: Minor
        Found in app/models/cake.rb - About 35 mins to fix

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

            def complete(count, answer = nil, total_score)
              if size.nil?
                cols = '70'
                rows = '1'
              else
          Severity: Minor
          Found in app/models/cake.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 get_total_score_for_questions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.get_total_score_for_questions(review_type, questions, participant_id, assignment_id, reviewee_id)
              total_scores = {}
              questions.each do |question|
                next unless question.instance_of? Cake
          
          
          Severity: Minor
          Found in app/models/cake.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

          Missing top-level class documentation comment.
          Open

          class Cake < ScoredQuestion
          Severity: Minor
          Found in app/models/cake.rb by rubocop

          This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

          The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

          Example:

          # bad
          class Person
            # ...
          end
          
          # good
          # Description/Explanation of Person class
          class Person
            # ...
          end

          Optional arguments should appear at the end of the argument list.
          Open

            def complete(count, answer = nil, total_score)
          Severity: Minor
          Found in app/models/cake.rb by rubocop

          This cop checks for optional arguments to methods that do not come at the end of the argument list

          Example:

          # bad
          def foo(a = 1, b, c)
          end
          
          # good
          def baz(a, b, c = 1)
          end
          
          def foobar(a = 1, b = 2, c = 3)
          end

          There are no issues that match your filters.

          Category
          Status