lib/timeline/component/item/Item.js

Summary

Maintainability
F
3 days
Test Coverage

Function _updateContents has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

Item.prototype._updateContents = function (element) {
  var content;
  var changed;
  var templateFunction;
  var itemVisibleFrameContent;
Severity: Minor
Found in lib/timeline/component/item/Item.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

File Item.js has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var Hammer = require('../../../module/hammer');
var util = require('../../../util');
var moment = require('../../../module/moment');


Severity: Minor
Found in lib/timeline/component/item/Item.js - About 4 hrs to fix

    Function _repaintOnItemUpdateTimeTooltip has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    Item.prototype._repaintOnItemUpdateTimeTooltip = function (anchor) {
      if (!this.options.tooltipOnItemUpdateTime) return;
    
      var editable = (this.options.editable.updateTime || 
                      this.data.editable === true) &&
    Severity: Minor
    Found in lib/timeline/component/item/Item.js - About 3 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 _updateContents has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Item.prototype._updateContents = function (element) {
      var content;
      var changed;
      var templateFunction;
      var itemVisibleFrameContent;
    Severity: Major
    Found in lib/timeline/component/item/Item.js - About 2 hrs to fix

      Function _repaintOnItemUpdateTimeTooltip has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Item.prototype._repaintOnItemUpdateTimeTooltip = function (anchor) {
        if (!this.options.tooltipOnItemUpdateTime) return;
      
        var editable = (this.options.editable.updateTime || 
                        this.data.editable === true) &&
      Severity: Major
      Found in lib/timeline/component/item/Item.js - About 2 hrs to fix

        Function _repaintDragCenter has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Item.prototype._repaintDragCenter = function () {
          if (this.selected && this.options.editable.updateTime && !this.dom.dragCenter) {
            var me = this;
            // create and show drag area
            var dragCenter = document.createElement('div');
        Severity: Minor
        Found in lib/timeline/component/item/Item.js - About 1 hr to fix

          Function _updateEditStatus has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          Item.prototype._updateEditStatus = function() {
            if (this.options) {
              if(typeof this.options.editable === 'boolean') {
                this.editable = {
                  updateTime: this.options.editable,
          Severity: Minor
          Found in lib/timeline/component/item/Item.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 _repaintDragCenter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          Item.prototype._repaintDragCenter = function () {
            if (this.selected && this.options.editable.updateTime && !this.dom.dragCenter) {
              var me = this;
              // create and show drag area
              var dragCenter = document.createElement('div');
          Severity: Minor
          Found in lib/timeline/component/item/Item.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 _repaintDeleteButton has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          Item.prototype._repaintDeleteButton = function (anchor) {
            var editable = ((this.options.editable.overrideItems || this.editable == null) && this.options.editable.remove) ||
                           (!this.options.editable.overrideItems && this.editable != null && this.editable.remove);
          
            if (this.selected && editable && !this.dom.deleteButton) {
          Severity: Minor
          Found in lib/timeline/component/item/Item.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 _updateDataAttributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

           Item.prototype._updateDataAttributes = function(element) {
            if (this.options.dataAttributes && this.options.dataAttributes.length > 0) {
              var attributes = [];
          
              if (Array.isArray(this.options.dataAttributes)) {
          Severity: Minor
          Found in lib/timeline/component/item/Item.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 _updateEditStatus has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Item.prototype._updateEditStatus = function() {
            if (this.options) {
              if(typeof this.options.editable === 'boolean') {
                this.editable = {
                  updateTime: this.options.editable,
          Severity: Minor
          Found in lib/timeline/component/item/Item.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                      if (!(this.data.type == 'background' && this.data.content === undefined)) {
                        throw new Error('Property "content" missing in item ' + this.id);
                      }
            Severity: Major
            Found in lib/timeline/component/item/Item.js - About 45 mins to fix

              TODO found
              Open

               *                                  // TODO: describe available options
              Severity: Minor
              Found in lib/timeline/component/item/Item.js by fixme

              TODO found
              Open

                  // TODO: be able to destroy the delete button
              Severity: Minor
              Found in lib/timeline/component/item/Item.js by fixme

              TODO found
              Open

                      // TODO: in vis.js 5.0, we should change this to not reset options from the timeline configuration.
              Severity: Minor
              Found in lib/timeline/component/item/Item.js by fixme

              TODO found
              Open

                  var tooltipOffset = 50; // TODO: should be tooltip height (depends on template)
              Severity: Minor
              Found in lib/timeline/component/item/Item.js by fixme

              TODO found
              Open

                    // TODO: this.top for orientation:true is actually the items distance from the bottom... 
              Severity: Minor
              Found in lib/timeline/component/item/Item.js by fixme

              There are no issues that match your filters.

              Category
              Status