SimpliField/oh-csv

View on GitHub

Showing 10 of 22 total issues

Function csvParserTransform has a Cognitive Complexity of 126 (exceeds 5 allowed). Consider refactoring.
Open

CSVParser.prototype._transform = function csvParserTransform(chunk, encoding, cb) {
  var _self = this;
  var string = chunk.toString();
  var matches;
  var curChar;
Severity: Minor
Found in src/index.js - About 2 days 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 csvParserTransform has 183 lines of code (exceeds 25 allowed). Consider refactoring.
Open

CSVParser.prototype._transform = function csvParserTransform(chunk, encoding, cb) {
  var _self = this;
  var string = chunk.toString();
  var matches;
  var curChar;
Severity: Major
Found in src/index.js - About 7 hrs to fix

    File index.js has 393 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var Stream = require('readable-stream');
    var util = require('util');
    var escapeRegExpComponent = require('escape-string-regexp');
    
    // Predefined configuration
    Severity: Minor
    Found in src/index.js - About 5 hrs to fix

      Function checkOptions has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

      function checkOptions(options) {
        options = options || {};
        // Separators (required)
        if(options.sep && 'string' === typeof options.sep) {
          options.sep = [options.sep];
      Severity: Minor
      Found in src/index.js - 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

      Function checkOptions has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function checkOptions(options) {
        options = options || {};
        // Separators (required)
        if(options.sep && 'string' === typeof options.sep) {
          options.sep = [options.sep];
      Severity: Minor
      Found in src/index.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                  if(_self.options.fields) {
                    _self.push(_self.options.fields.reduce(function(obj, field) {
                      obj[field] = _self._currentRow.shift();
                      return obj;
                    }, {}));
        Severity: Major
        Found in src/index.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if(i  < 0) {
                      string = _self._startQuotState.substr(0, -i) + string;
                      i = -1;
                    }
          Severity: Major
          Found in src/index.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if(i  < 0) {
                        string = _self._escState.substr(0, -i) + string;
                        i = -1;
                      }
            Severity: Major
            Found in src/index.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if(i  < 0) {
                          string = _self._endQuotState.substr(0, -i) + string;
                          i = -1;
                        }
              Severity: Major
              Found in src/index.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          if(i  < 0) {
                            string = (_self._escState + _self._escChars).substr(0, -i) + string;
                            i = -1;
                          }
                Severity: Major
                Found in src/index.js - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language