lib/DataSet.js

Summary

Maintainability
F
5 days
Test Coverage

File DataSet.js has 574 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var util = require('./util');
var Queue = require('./Queue');

/**
 * DataSet
Severity: Major
Found in lib/DataSet.js - About 1 day to fix

    Function get has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

    DataSet.prototype.get = function (args) {  // eslint-disable-line no-unused-vars
      var me = this;
    
      // parse the arguments
      var id, ids, options;
    Severity: Minor
    Found in lib/DataSet.js - About 6 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 getIds has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    DataSet.prototype.getIds = function (options) {
      var data = this._data,
          filter = options && options.filter,
          order = options && options.order,
          type = options && options.type || this._options.type,
    Severity: Minor
    Found in lib/DataSet.js - 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 get has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    DataSet.prototype.get = function (args) {  // eslint-disable-line no-unused-vars
      var me = this;
    
      // parse the arguments
      var id, ids, options;
    Severity: Major
    Found in lib/DataSet.js - About 3 hrs to fix

      Function getIds has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      DataSet.prototype.getIds = function (options) {
        var data = this._data,
            filter = options && options.filter,
            order = options && options.order,
            type = options && options.type || this._options.type,
      Severity: Major
      Found in lib/DataSet.js - About 2 hrs to fix

        Function distinct has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        DataSet.prototype.distinct = function (field) {
          var data = this._data;
          var itemIds = Object.keys(data);
          var values = [];
          var fieldType = this._options.type && this._options.type[field] || null;
        Severity: Minor
        Found in lib/DataSet.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 setOptions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        DataSet.prototype.setOptions = function(options) {
          if (options && options.queue !== undefined) {
            if (options.queue === false) {
              // delete queue if loaded
              if (this._queue) {
        Severity: Minor
        Found in lib/DataSet.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 update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        DataSet.prototype.update = function (data, senderId) {
          var addedIds = [];
          var updatedIds = [];
          var oldData = [];
          var updatedData = [];
        Severity: Minor
        Found in lib/DataSet.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 update has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        DataSet.prototype.update = function (data, senderId) {
          var addedIds = [];
          var updatedIds = [];
          var oldData = [];
          var updatedData = [];
        Severity: Minor
        Found in lib/DataSet.js - About 1 hr to fix

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

          DataSet.prototype._filterFields = function (item, fields) {
            if (!item) { // item is null
              return item;
            }
          
          
          Severity: Minor
          Found in lib/DataSet.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 forEach has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          DataSet.prototype.forEach = function (callback, options) {
            var filter = options && options.filter,
                type = options && options.type || this._options.type,
                data = this._data,
                itemIds = Object.keys(data),
          Severity: Minor
          Found in lib/DataSet.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 DataSet has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function DataSet (data, options) {
            // correctly read optional arguments
            if (data && !Array.isArray(data)) {
              options = data;
              data = null;
          Severity: Minor
          Found in lib/DataSet.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 distinct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          DataSet.prototype.distinct = function (field) {
            var data = this._data;
            var itemIds = Object.keys(data);
            var values = [];
            var fieldType = this._options.type && this._options.type[field] || null;
          Severity: Minor
          Found in lib/DataSet.js - About 1 hr to fix

            Function DataSet has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function DataSet (data, options) {
              // correctly read optional arguments
              if (data && !Array.isArray(data)) {
                options = data;
                data = null;
            Severity: Minor
            Found in lib/DataSet.js - About 1 hr to fix

              Function remove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              DataSet.prototype.remove = function (id, senderId) {
                var removedIds = [],
                    removedItems = [],
                    ids = [],
                    i, len, itemId, item;
              Severity: Minor
              Found in lib/DataSet.js - About 45 mins 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 _getItem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              DataSet.prototype._getItem = function (id, types) {
                var field, value, i, len;
              
                // get the item from the dataset
                var raw = this._data[id];
              Severity: Minor
              Found in lib/DataSet.js - About 45 mins 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 _trigger has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              DataSet.prototype._trigger = function (event, params, senderId) {
                if (event == '*') {
                  throw new Error('Cannot trigger event *');
                }
              
              
              Severity: Minor
              Found in lib/DataSet.js - About 35 mins 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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              DataSet.prototype.add = function (data, senderId) {
                var addedIds = [],
                    id,
                    me = this;
              
              
              Severity: Minor
              Found in lib/DataSet.js - About 35 mins 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 map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              DataSet.prototype.map = function (callback, options) {
                var filter = options && options.filter,
                    type = options && options.type || this._options.type,
                    mappedItems = [],
                    data = this._data,
              Severity: Minor
              Found in lib/DataSet.js - About 25 mins 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

              TODO found
              Open

                // TODO: extend order by an Object {field:string, direction:string}
              Severity: Minor
              Found in lib/DataSet.js by fixme

              TODO found
              Open

                  // TODO: remove deprecated property 'data' some day
              Severity: Minor
              Found in lib/DataSet.js by fixme

              TODO found
              Open

               * // TODO: add a DataSet constructor DataSet(data, options)
              Severity: Minor
              Found in lib/DataSet.js by fixme

              There are no issues that match your filters.

              Category
              Status