app/assets/scripts/upload-csv.js
Function submitCsvData
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function parseCSV
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Open
function parseCSV() {
var numRows = 0;
var numFields = 0;
var errorList = [];
var rowObjects = [];
- Read upRead up
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
Open
function parseCSV() {
var numRows = 0;
var numFields = 0;
var errorList = [];
var rowObjects = [];
Function step
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
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();
Function submitCsvData
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
Open
DeferredAjax.prototype.invoke = function() {
var self = this;
var data = {
action: self.action,
row: self.row,