autolab/Autolab

View on GitHub

Showing 572 of 572 total issues

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

    Function func has 135 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            var func = function(e) {
                e = e || window.event;
                
                if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields
                    var element;
    Severity: Major
    Found in app/assets/javascripts/shortcut.js - About 5 hrs to fix

      Method tango_plot_data has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

        def tango_plot_data(live_jobs = nil, dead_jobs = nil)
          live_jobs ||= TangoClient.jobs
          dead_jobs ||= TangoClient.jobs(1)
          @plot_data = { new_jobs: { name: "New Job Requests", dates: [], job_name: [], job_id: [],
                                     vm_pool: [], vm_id: [], status: [], duration: [] },
      Severity: Minor
      Found in app/controllers/jobs_controller.rb - About 5 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

      Function compileType3Glyph has 127 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function compileType3Glyph(imgData) {
        var POINT_TO_PROCESS_LIMIT = 1000;
      
        var width = imgData.width, height = imgData.height;
        var i, j, j0, width1 = width + 1;
      Severity: Major
      Found in app/assets/javascripts/pdf.js - About 5 hrs to fix

        Function AutoColumnSize has 124 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function AutoColumnSize(maxWidth) {
        
                var grid, $container, context,
                    keyCodes = {
                        'A': 65
        Severity: Major
        Found in app/assets/javascripts/SlickGrid/2.02/plugins/slick.autocolumnsize.js - About 4 hrs to fix

          Method saveAutograde has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

            def saveAutograde(submissions, feedback)
              begin
                # Set job id to nil to indicate that autograding is no longer in-progress
                ActiveRecord::Base.transaction do
                  submissions.each do |submission|
          Severity: Minor
          Found in app/helpers/assessment_autograde_core.rb - About 4 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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                for (var i = 0; i < columns.length; i++) {
                  var m = columns[i] = $.extend({}, columnDefaults, columns[i]);
                  columnsById[m.id] = i;
                  if (m.minWidth && m.width < m.minWidth) {
                    m.width = m.minWidth;
          Severity: Major
          Found in app/assets/javascripts/SlickGrid/2.02/slick.grid.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/SlickGrid/2.02/slick.grid.js on lines 1189..1198

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 133.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                for (var i = 0; i < columns.length; i++) {
                  var m = columns[i] = $.extend({}, columnDefaults, columns[i]);
                  columnsById[m.id] = i;
                  if (m.minWidth && m.width < m.minWidth) {
                    m.width = m.minWidth;
          Severity: Major
          Found in app/assets/javascripts/SlickGrid/2.02/slick.grid.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/SlickGrid/2.02/slick.grid.js on lines 199..208

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 133.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              function use_default_late_penalty_callback() {
                const checked = $(this).prop('checked');
                const $latePenaltyValue = $('#assessment_late_penalty_attributes_value');
                const $latePenaltyField = $latePenaltyValue.parent();
                $latePenaltyField.find('input').prop('disabled', checked);
          Severity: Major
          Found in app/assets/javascripts/edit_assessment.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/edit_assessment.js on lines 105..116

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 131.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              function use_default_version_penalty_callback() {
                const checked = $(this).prop('checked');
                const $versionPenaltyValue = $('#assessment_version_penalty_attributes_value');
                const $versionPenaltyField = $versionPenaltyValue.parent();
                $versionPenaltyField.find('input').prop('disabled', checked);
          Severity: Major
          Found in app/assets/javascripts/edit_assessment.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/edit_assessment.js on lines 79..90

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 131.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          File jquery.jeditable.js has 363 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*
           * Jeditable - jQuery in place edit plugin
           *
           * Copyright (c) 2006-2009 Mika Tuupola, Dylan Verheul
           *
          Severity: Minor
          Found in app/assets/javascripts/jquery.jeditable.js - About 4 hrs to fix

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                            for (j = i; j >= 0; j--) {
                              c = columns[j];
                              if (c.resizable) {
                                actualMinWidth = Math.max(c.minWidth || 0, absoluteColumnMinWidth);
                                if (x && c.previousWidth + x < actualMinWidth) {
            Severity: Major
            Found in app/assets/javascripts/SlickGrid/2.02/slick.grid.js and 1 other location - About 4 hrs to fix
            app/assets/javascripts/SlickGrid/2.02/slick.grid.js on lines 829..841

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 129.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                              for (j = i + 1; j < columnElements.length; j++) {
                                c = columns[j];
                                if (c.resizable) {
                                  actualMinWidth = Math.max(c.minWidth || 0, absoluteColumnMinWidth);
                                  if (x && c.previousWidth + x < actualMinWidth) {
            Severity: Major
            Found in app/assets/javascripts/SlickGrid/2.02/slick.grid.js and 1 other location - About 4 hrs to fix
            app/assets/javascripts/SlickGrid/2.02/slick.grid.js on lines 783..795

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 129.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  if (rotateA === 0) {
                    offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
                    offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
                    width = Math.abs(viewBox[3] - viewBox[1]) * scale;
                    height = Math.abs(viewBox[2] - viewBox[0]) * scale;
              Severity: Major
              Found in app/assets/javascripts/pdf.js and 1 other location - About 4 hrs to fix
              app/assets/javascripts/pdf.js on lines 871..876

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 127.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  } else {
                    offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
                    offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
                    width = Math.abs(viewBox[2] - viewBox[0]) * scale;
                    height = Math.abs(viewBox[3] - viewBox[1]) * scale;
              Severity: Major
              Found in app/assets/javascripts/pdf.js and 1 other location - About 4 hrs to fix
              app/assets/javascripts/pdf.js on lines 866..871

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 127.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                                for (j = i + 1; j < columnElements.length; j++) {
                                  c = columns[j];
                                  if (c.resizable) {
                                    if (x && c.maxWidth && (c.maxWidth - c.previousWidth < x)) {
                                      x -= c.maxWidth - c.previousWidth;
              Severity: Major
              Found in app/assets/javascripts/SlickGrid/2.02/slick.grid.js and 1 other location - About 4 hrs to fix
              app/assets/javascripts/SlickGrid/2.02/slick.grid.js on lines 814..825

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 125.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                              for (j = i; j >= 0; j--) {
                                c = columns[j];
                                if (c.resizable) {
                                  if (x && c.maxWidth && (c.maxWidth - c.previousWidth < x)) {
                                    x -= c.maxWidth - c.previousWidth;
              Severity: Major
              Found in app/assets/javascripts/SlickGrid/2.02/slick.grid.js and 1 other location - About 4 hrs to fix
              app/assets/javascripts/SlickGrid/2.02/slick.grid.js on lines 799..810

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 125.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Method gradebook_rows has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                def gradebook_rows(matrix, course, section = nil, lecture = nil)
                  rows = []
              
                  course.course_user_data.each do |cud|
                    next unless matrix.has_cud? cud.id
              Severity: Minor
              Found in app/helpers/gradebook_helper.rb - About 4 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 shibboleth has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                def shibboleth
                  if user_signed_in?
                    if (data = request.env["omniauth.auth"]) && current_user.authentications.where(provider: "CMU-Shibboleth",
                                                                                                   uid: data["uid"]).empty?
                      current_user.authentications.create(provider: "CMU-Shibboleth",
              Severity: Minor
              Found in app/controllers/users/omniauth_callbacks_controller.rb - About 4 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

              Severity
              Category
              Status
              Source
              Language