autolab/Autolab

View on GitHub
app/controllers/scoreboards_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Method show has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    # It turns out that it's faster to just get everything and let the
    # view handle it
    problemQuery = "SELECT scores.score AS score,
        submissions.version AS version,
Severity: Minor
Found in app/controllers/scoreboards_controller.rb - About 1 day 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 show has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    # It turns out that it's faster to just get everything and let the
    # view handle it
    problemQuery = "SELECT scores.score AS score,
        submissions.version AS version,
Severity: Major
Found in app/controllers/scoreboards_controller.rb - About 4 hrs to fix

    File scoreboards_controller.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class ScoreboardsController < ApplicationController
      before_action :set_assessment
      before_action :set_assessment_breadcrumb
      before_action :set_edit_assessment_breadcrumb, only: [:edit]
      before_action :set_scoreboard, except: [:create]
    Severity: Minor
    Found in app/controllers/scoreboards_controller.rb - About 2 hrs to fix

      Method scoreboardOrderSubmissions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def scoreboardOrderSubmissions(a, b)
          # If the assessment is not autograded, or the instructor did
          # not create a custom column spec, then revert to the default,
          # which sorts by total problem, then by submission time.
          if !@assessment.has_autograder? ||
      Severity: Minor
      Found in app/controllers/scoreboards_controller.rb - About 2 hrs 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 scoreboardOrderSubmissions has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def scoreboardOrderSubmissions(a, b)
          # If the assessment is not autograded, or the instructor did
          # not create a custom column spec, then revert to the default,
          # which sorts by total problem, then by submission time.
          if !@assessment.has_autograder? ||
      Severity: Minor
      Found in app/controllers/scoreboards_controller.rb - About 1 hr to fix

        Method createScoreboardEntry has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def createScoreboardEntry(scores, autoresult)
            # If the assessment was not autograded or the scoreboard was
            # not customized, then simply return the list of problem
            # scores and their total.
            if !autoresult ||
        Severity: Minor
        Found in app/controllers/scoreboards_controller.rb - About 1 hr to fix

          Method emitColSpec has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def emitColSpec(colspec)
              return "Empty column specification" if colspec.blank?
          
              begin
                # Quote JSON keys and values if they are not already quoted
          Severity: Minor
          Found in app/controllers/scoreboards_controller.rb - About 1 hr to fix

            Method emitColSpec has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def emitColSpec(colspec)
                return "Empty column specification" if colspec.blank?
            
                begin
                  # Quote JSON keys and values if they are not already quoted
            Severity: Minor
            Found in app/controllers/scoreboards_controller.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

            Avoid too many return statements within this method.
            Open

                    render("scoreboards/edit") && return
            Severity: Major
            Found in app/controllers/scoreboards_controller.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      redirect_to(course_assessment_path(@course, @assessment)) && return
              Severity: Major
              Found in app/controllers/scoreboards_controller.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return unless @scoreboard.colspec.present?
                Severity: Major
                Found in app/controllers/scoreboards_controller.rb - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status