lib/timeline/Timeline.js

Summary

Maintainability
F
4 days
Test Coverage

File Timeline.js has 504 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var moment = require('../module/moment');
var util = require('../util');
var DataSet = require('../DataSet');
var DataView = require('../DataView');
var Range = require('./Range');
Severity: Major
Found in lib/timeline/Timeline.js - About 1 day to fix

    Function Timeline has 145 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function Timeline (container, items, groups, options) {
    
      if (!(this instanceof Timeline)) {
        throw new SyntaxError('Constructor must be called with the new operator');
      }
    Severity: Major
    Found in lib/timeline/Timeline.js - About 5 hrs to fix

      Function focus has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      Timeline.prototype.focus = function(id, options) {
        if (!this.itemsData || id == undefined) return;
      
        var ids = Array.isArray(id) ? id : [id];
      
      
      Severity: Minor
      Found in lib/timeline/Timeline.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 getItemRange has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      Timeline.prototype.getItemRange = function () {
        // get a rough approximation for the range based on the items start and end dates
        var range = this.getDataRange();
        var min = range.min !== null ? range.min.valueOf() : null;
        var max = range.max !== null ? range.max.valueOf() : null;
      Severity: Minor
      Found in lib/timeline/Timeline.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 getItemRange has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Timeline.prototype.getItemRange = function () {
        // get a rough approximation for the range based on the items start and end dates
        var range = this.getDataRange();
        var min = range.min !== null ? range.min.valueOf() : null;
        var max = range.max !== null ? range.max.valueOf() : null;
      Severity: Major
      Found in lib/timeline/Timeline.js - About 2 hrs to fix

        Function focus has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Timeline.prototype.focus = function(id, options) {
          if (!this.itemsData || id == undefined) return;
        
          var ids = Array.isArray(id) ? id : [id];
        
        
        Severity: Major
        Found in lib/timeline/Timeline.js - About 2 hrs to fix

          Function getEventProperties has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          Timeline.prototype.getEventProperties = function (event) {
            var clientX = event.center ? event.center.x : event.clientX;
            var clientY = event.center ? event.center.y : event.clientY;
            var x;
            if (this.options.rtl) {
          Severity: Minor
          Found in lib/timeline/Timeline.js - About 2 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 Timeline has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          function Timeline (container, items, groups, options) {
          
            if (!(this instanceof Timeline)) {
              throw new SyntaxError('Constructor must be called with the new operator');
            }
          Severity: Minor
          Found in lib/timeline/Timeline.js - About 2 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 getEventProperties has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Timeline.prototype.getEventProperties = function (event) {
            var clientX = event.center ? event.center.x : event.clientX;
            var clientY = event.center ? event.center.y : event.clientY;
            var x;
            if (this.options.rtl) {
          Severity: Minor
          Found in lib/timeline/Timeline.js - About 1 hr to fix

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

            function getItemVerticalScroll(timeline, item) {
              var leftHeight = timeline.props.leftContainer.height;
              var contentHeight = timeline.props.left.height;
              
              var group = item.parent;
            Severity: Minor
            Found in lib/timeline/Timeline.js - About 1 hr to fix

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

              function getItemVerticalScroll(timeline, item) {
                var leftHeight = timeline.props.leftContainer.height;
                var contentHeight = timeline.props.left.height;
                
                var group = item.parent;
              Severity: Minor
              Found in lib/timeline/Timeline.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 setOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              Timeline.prototype.setOptions = function (options) {
                // validate options
                let errorFound = Validator.validate(options, allOptions);
              
                if (errorFound === true) {
              Severity: Minor
              Found in lib/timeline/Timeline.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 setGroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              Timeline.prototype.setGroups = function(groups) {
                // convert to type DataSet when needed
                var newDataSet;
                if (!groups) {
                  newDataSet = null;
              Severity: Minor
              Found in lib/timeline/Timeline.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: REMOVE THIS in the next MAJOR release
              Severity: Minor
              Found in lib/timeline/Timeline.js by fixme

              There are no issues that match your filters.

              Category
              Status