hack4impact/maps4all

View on GitHub
app/assets/scripts/upload-csv.js

Summary

Maintainability
D
1 day
Test Coverage

Function submitCsvData has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function submitCsvData(numRows, rowObjects, fields) {
  // Create list of Ajax requests: first processing the fields of the CSV then
  // the rows
  var ajaxReqs = [];
  var resetOrUpdate = document.getElementById('reset').checked
Severity: Major
Found in app/assets/scripts/upload-csv.js - About 4 hrs to fix

    Function parseCSV has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function parseCSV() {
      var numRows = 0;
      var numFields = 0;
      var errorList = [];
      var rowObjects = [];
    Severity: Minor
    Found in app/assets/scripts/upload-csv.js - 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

    Function parseCSV has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function parseCSV() {
      var numRows = 0;
      var numFields = 0;
      var errorList = [];
      var rowObjects = [];
    Severity: Major
    Found in app/assets/scripts/upload-csv.js - About 2 hrs to fix

      Function step has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            step: function(row, parser) {
              // Check CSV formatting before parsing first row
              if (numRows == 0) {
                fields = row.meta.fields.map(function(e) {
                  return e.trim();
      Severity: Minor
      Found in app/assets/scripts/upload-csv.js - About 1 hr to fix

        Function submitCsvData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function submitCsvData(numRows, rowObjects, fields) {
          // Create list of Ajax requests: first processing the fields of the CSV then
          // the rows
          var ajaxReqs = [];
          var resetOrUpdate = document.getElementById('reset').checked
        Severity: Minor
        Found in app/assets/scripts/upload-csv.js - 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

        Function invoke has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          DeferredAjax.prototype.invoke = function() {
            var self = this;
            var data = {
              action: self.action,
              row: self.row,
        Severity: Minor
        Found in app/assets/scripts/upload-csv.js - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status