autolab/Autolab

View on GitHub
app/controllers/assessment/grading.rb

Summary

Maintainability
F
3 days
Test Coverage

File grading.rb has 392 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "csv"
require "utilities"

module AssessmentGrading
  # Export all scores for an assessment for all students as CSV
Severity: Minor
Found in app/controllers/assessment/grading.rb - About 5 hrs to fix

    Method save_entries has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      def save_entries(entries, data_type)
        asmt = @assessment
    
        begin
          User.transaction do
    Severity: Minor
    Found in app/controllers/assessment/grading.rb - About 3 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 parse_csv_row has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_csv_row(row, kind, problems, emails)
        row = row.dup
    
        email = row.shift.to_s
        data = row.shift problems.count
    Severity: Minor
    Found in app/controllers/assessment/grading.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 stats_for_grader has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def stats_for_grader(submissions)
        result = []
        problem_id_to_name = @assessment.problem_id_to_name
        stats = Statistics.new
    
    
    Severity: Minor
    Found in app/controllers/assessment/grading.rb - About 1 hr to fix

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

        def quickSetScore
          return unless request.post?
          return unless params[:submission_id]
          return unless params[:problem_id]
      
      
      Severity: Minor
      Found in app/controllers/assessment/grading.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 quickSetScoreDetails has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def quickSetScoreDetails
          return unless request.post?
          return unless params[:submission_id]
          return unless params[:problem_id]
           # get submission and problem IDs
      Severity: Minor
      Found in app/controllers/assessment/grading.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 bulkGrade has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def bulkGrade
          return unless request.post?
      
          # part 1: submitting a CSV for processing and returning errors in CSV
          if params[:upload]
      Severity: Minor
      Found in app/controllers/assessment/grading.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_entries has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def save_entries(entries, data_type)
          asmt = @assessment
      
          begin
            User.transaction do
      Severity: Minor
      Found in app/controllers/assessment/grading.rb - About 1 hr to fix

        Method parse_csv_row has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def parse_csv_row(row, kind, problems, emails)
            row = row.dup
        
            email = row.shift.to_s
            data = row.shift problems.count
        Severity: Minor
        Found in app/controllers/assessment/grading.rb - About 1 hr to fix

          Method stats_for_grader has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def stats_for_grader(submissions)
              result = []
              problem_id_to_name = @assessment.problem_id_to_name
              stats = Statistics.new
          
          
          Severity: Minor
          Found in app/controllers/assessment/grading.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 statistics has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def statistics
              load_course_config
              latest_submissions = @assessment.submissions.latest_for_statistics.includes(:scores, :course_user_datum)
              #latest_submissions = @assessment.submissions.latest.includes(:scores, :course_user_datum)
          
          
          Severity: Minor
          Found in app/controllers/assessment/grading.rb - About 1 hr to fix

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

              def bulkGrade_complete
                redirect_to(action: :bulkGrade) && return unless request.post?
            
                # retrieve entries CSV from hidden field in form
                csv = params[:confirm][:bulkGrade_csv]
            Severity: Minor
            Found in app/controllers/assessment/grading.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

            Avoid too many return statements within this method.
            Open

                  redirect_to(action: :bulkGrade) && return
            Severity: Major
            Found in app/controllers/assessment/grading.rb - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status