SimpliField/oh-csv

View on GitHub

Showing 22 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

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

            if(-1 !== _self.options.linesep.indexOf(_self._lnSep)) {
              // Got a valid new line char
              if('' !== _self._currentField || 0 < _self._currentRow.length) {
                _self._currentRow.push(_self._currentField);
                _self._currentField = '';
      Severity: Major
      Found in src/index.js and 3 other locations - About 2 hrs to fix
      src/index.js on lines 188..199
      src/index.js on lines 272..284
      src/index.js on lines 308..321

      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 86.

      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 4 locations. Consider refactoring.
      Open

              if(-1 !== _self.options.quote.indexOf(_self._startQuotState)) {
                _self._parsingState |= CSVParser.STATE_FIELD_QUOTED;
                i--;
              } else {
                // Got an invalid quote char, reinjecting to the string
      Severity: Major
      Found in src/index.js and 3 other locations - About 2 hrs to fix
      src/index.js on lines 272..284
      src/index.js on lines 308..321
      src/index.js on lines 338..366

      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 86.

      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 4 locations. Consider refactoring.
      Open

            if(-1 !== _self.options.sep.indexOf(_self._fSep)) {
              // Got a valid separator char
              _self._currentRow.push(_self._currentField);
              _self._currentField = '';
              i--;
      Severity: Major
      Found in src/index.js and 3 other locations - About 2 hrs to fix
      src/index.js on lines 188..199
      src/index.js on lines 272..284
      src/index.js on lines 338..366

      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 86.

      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 4 locations. Consider refactoring.
      Open

              if(_self._startQuotState === _self._endQuotState) {
                _self._parsingState ^= CSVParser.STATE_QUOTE_END;
                _self._parsingState ^= CSVParser.STATE_FIELD_QUOTED;
                i--;
              } else {
      Severity: Major
      Found in src/index.js and 3 other locations - About 2 hrs to fix
      src/index.js on lines 188..199
      src/index.js on lines 308..321
      src/index.js on lines 338..366

      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 86.

      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

      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

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

            if(!this._discardFSep && ! (_self._parsingState&CSVParser.STATE_LNSEP)) {
              matches = getSeparatorMatches(_self.options.sep, _self._fSep + curChar);
              if(matches.length) {
                _self._fSep += curChar;
                _self._parsingState |= CSVParser.STATE_FSEP;
        Severity: Major
        Found in src/index.js and 2 other locations - About 1 hr to fix
        src/index.js on lines 233..245
        src/index.js on lines 326..333

        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 70.

        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 3 locations. Consider refactoring.
        Open

              if((!_self._discardEsc) && !(
                  _self._parsingState&CSVParser.STATE_FSEP ||
                  _self._parsingState&CSVParser.STATE_LNSEP ||
                  _self._parsingState&CSVParser.STATE_QUOTE_START ||
                  _self._parsingState&CSVParser.STATE_QUOTE_END
        Severity: Major
        Found in src/index.js and 2 other locations - About 1 hr to fix
        src/index.js on lines 296..303
        src/index.js on lines 326..333

        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 70.

        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 3 locations. Consider refactoring.
        Open

            if(!this._discardLn) {
              matches = getSeparatorMatches(_self.options.linesep, _self._lnSep + curChar);
              if(matches.length) {
                _self._lnSep += curChar;
                _self._parsingState |= CSVParser.STATE_LNSEP;
        Severity: Major
        Found in src/index.js and 2 other locations - About 1 hr to fix
        src/index.js on lines 233..245
        src/index.js on lines 296..303

        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 70.

        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 3 locations. Consider refactoring.
        Open

        var tsvOpts = {
          sep: ['\t'],
          linesep: ['\r\n', '\n', '\r'],
          quote: ['"'],
          toQuote: [',', '\r\n', '\n', '\r'],
        Severity: Major
        Found in src/index.js and 2 other locations - About 1 hr to fix
        src/index.js on lines 11..18
        src/index.js on lines 27..34

        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 55.

        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 3 locations. Consider refactoring.
        Open

        var csvQuotOpts = {
          sep: [','],
          linesep: ['\r\n', '\n', '\r'],
          quote: ['"'],
          toQuote: [',', '\r\n', '\n', '\r'],
        Severity: Major
        Found in src/index.js and 2 other locations - About 1 hr to fix
        src/index.js on lines 19..26
        src/index.js on lines 27..34

        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 55.

        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 3 locations. Consider refactoring.
        Open

        var tsvQuotOpts = {
          sep: ['\t'],
          linesep: ['\r\n', '\n', '\r'],
          quote: ['"'],
          toQuote: ['\t', '\r\n', '\n', '\r'],
        Severity: Major
        Found in src/index.js and 2 other locations - About 1 hr to fix
        src/index.js on lines 11..18
        src/index.js on lines 19..26

        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 55.

        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

        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