lib/DataView.js

Summary

Maintainability
D
2 days
Test Coverage

Function _onEvent has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

DataView.prototype._onEvent = function (event, params, senderId) {
  var i, len, id, item;
  var ids = params && params.items;
  var addedIds = [],
      updatedIds = [],
Severity: Minor
Found in lib/DataView.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 _onEvent has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

DataView.prototype._onEvent = function (event, params, senderId) {
  var i, len, id, item;
  var ids = params && params.items;
  var addedIds = [],
      updatedIds = [],
Severity: Major
Found in lib/DataView.js - About 2 hrs to fix

    Function setData has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    DataView.prototype.setData = function (data) {
      var ids, id, i, len, items;
    
      if (this._data) {
        // unsubscribe from current dataset
    Severity: Minor
    Found in lib/DataView.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 refresh has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    DataView.prototype.refresh = function () {
      var id, i, len;
      var ids = this._data.getIds({filter: this._options && this._options.filter}),
          oldIds = Object.keys(this._ids),
          newIds = {},
    Severity: Minor
    Found in lib/DataView.js - About 1 hr to fix

      Function setData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      DataView.prototype.setData = function (data) {
        var ids, id, i, len, items;
      
        if (this._data) {
          // unsubscribe from current dataset
      Severity: Minor
      Found in lib/DataView.js - About 1 hr to fix

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

        DataView.prototype.getIds = function (options) {
          var ids;
        
          if (this._data) {
            var defaultFilter = this._options.filter;
        Severity: Minor
        Found in lib/DataView.js - About 1 hr to fix

          Function map has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          DataView.prototype.map = function (callback,options) {
            var mappedItems = [];
            if (this._data) {
              var defaultFilter = this._options.filter;
              var filter;
          Severity: Minor
          Found in lib/DataView.js - About 1 hr to fix

            Function getIds has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            DataView.prototype.getIds = function (options) {
              var ids;
            
              if (this._data) {
                var defaultFilter = this._options.filter;
            Severity: Minor
            Found in lib/DataView.js - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
            Open

            DataView.prototype.map = function (callback,options) {
              var mappedItems = [];
              if (this._data) {
                var defaultFilter = this._options.filter;
                var filter;
            Severity: Minor
            Found in lib/DataView.js - About 55 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 refresh has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            DataView.prototype.refresh = function () {
              var id, i, len;
              var ids = this._data.getIds({filter: this._options && this._options.filter}),
                  oldIds = Object.keys(this._ids),
                  newIds = {},
            Severity: Minor
            Found in lib/DataView.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

            Avoid deeply nested control flow statements.
            Open

                        if (this._ids[id]) {
                          delete this._ids[id];
                          removedIds.push(id);
                          removedItems.push(params.oldData[i]);
                        }
            Severity: Major
            Found in lib/DataView.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if (this._ids[id]) {
                            updatedIds.push(id);
                            updatedItems.push(params.data[i]);
                            oldItems.push(params.oldData[i]);
                          }
              Severity: Major
              Found in lib/DataView.js - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                  if (this._data) {
                    // update fieldId
                    this._fieldId = this._options.fieldId ||
                        (this._data && this._data.options && this._data.options.fieldId) ||
                        'id';
                Severity: Major
                Found in lib/DataView.js - About 40 mins to fix

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

                  DataView.prototype.get = function (args) {  // eslint-disable-line no-unused-vars
                    var me = this;
                  
                    // parse the arguments
                    var ids, options, data;
                  Severity: Minor
                  Found in lib/DataView.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: implement a function .config() to dynamically update things like configured filter
                  Severity: Minor
                  Found in lib/DataView.js by fixme

                  TODO found
                  Open

                  // TODO: make these functions deprecated (replaced with `on` and `off` since version 0.5)
                  Severity: Minor
                  Found in lib/DataView.js by fixme

                  There are no issues that match your filters.

                  Category
                  Status