cBioPortal/clinical-timeline

View on GitHub

Showing 92 of 92 total issues

Function clinicalTimeline has a Cognitive Complexity of 251 (exceeds 5 allowed). Consider refactoring.
Open

var clinicalTimeline = (function(){
  "use strict";

  var allData,
    colorCycle = d3.scale.category20(),
Severity: Minor
Found in js/clinicalTimeline.js - About 5 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 clinicalTimeline has 954 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var clinicalTimeline = (function(){
  "use strict";

  var allData,
    colorCycle = d3.scale.category20(),
Severity: Major
Found in js/clinicalTimeline.js - About 4 days to fix

    File clinicalTimeline.js has 959 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // vim: ts=2 sw=2
    /* start-test-code-not-included-in-build */
    d3 = require('d3');
    /* end-test-code-not-included-in-build */
    var clinicalTimeline = (function(){
    Severity: Major
    Found in js/clinicalTimeline.js - About 2 days to fix

      Function run has 171 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      trimClinicalTimeline.prototype.run = function (timeline, spec) {
        // skip when zoomed in, because trimming behaves oddly in those cases
        if (timeline.zoomFactor() !== 1) {
            return;
        }
      Severity: Major
      Found in js/plugins/trimTimeline.js - About 6 hrs to fix

        Function has too many statements (60). Maximum allowed is 30.
        Open

        var clinicalTimeline = (function(){
        Severity: Minor
        Found in js/clinicalTimeline.js by eslint

        enforce a maximum number of statements allowed in function blocks (max-statements)

        The max-statements rule allows you to specify the maximum number of statements allowed in a function.

        function foo() {
          var bar = 1; // one statement
          var baz = 2; // two statements
          var qux = 3; // three statements
        }

        Rule Details

        This rule enforces a maximum number of statements allowed in function blocks.

        Options

        This rule has a number or object option:

        • "max" (default 10) enforces a maximum number of statements allows in function blocks

        Deprecated: The object property maximum is deprecated; please use the object property max instead.

        This rule has an object option:

        • "ignoreTopLevelFunctions": true ignores top-level functions

        max

        Examples of incorrect code for this rule with the default { "max": 10 } option:

        /*eslint max-statements: ["error", 10]*/
        /*eslint-env es6*/
        
        function foo() {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
        
          var foo11 = 11; // Too many.
        }
        
        let foo = () => {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
        
          var foo11 = 11; // Too many.
        };

        Examples of correct code for this rule with the default { "max": 10 } option:

        /*eslint max-statements: ["error", 10]*/
        /*eslint-env es6*/
        
        function foo() {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
          return function () {
        
            // The number of statements in the inner function does not count toward the
            // statement maximum.
        
            return 42;
          };
        }
        
        let foo = () => {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
          return function () {
        
            // The number of statements in the inner function does not count toward the
            // statement maximum.
        
            return 42;
          };
        }

        ignoreTopLevelFunctions

        Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

        /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
        
        function foo() {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
          var foo11 = 11;
        }

        Related Rules

        • [complexity](complexity.md)
        • [max-depth](max-depth.md)
        • [max-len](max-len.md)
        • [max-nested-callbacks](max-nested-callbacks.md)
        • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

        Function run has 126 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        clinicalTimelineZoom.prototype.run = function(timeline, spec) {
          var readOnlyVars = timeline.getReadOnlyVars(),
            maxDays = readOnlyVars.maxDays,
            minDays = readOnlyVars.minDays,
            beginning = readOnlyVars.beginning,
        Severity: Major
        Found in js/plugins/zoom.js - About 5 hrs to fix

          Function run has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

          clinicalTimelineZoom.prototype.run = function(timeline, spec) {
            var readOnlyVars = timeline.getReadOnlyVars(),
              maxDays = readOnlyVars.maxDays,
              minDays = readOnlyVars.minDays,
              beginning = readOnlyVars.beginning,
          Severity: Minor
          Found in js/plugins/zoom.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

          Function timeline has 117 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function timeline() {
              var visibleData = allData.filter(function(x) {
                  return x.visible;
              });
          
          
          Severity: Major
          Found in js/clinicalTimeline.js - About 4 hrs to fix

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

              var overviewAxisMirror = d3.svg.axis().scale(xScaleOverview).orient("top")
                .tickFormat(function(d) { 
                  return timeline.formatTime(timeline.daysToTimeObject(d.valueOf()), originalZoomLevel);
                })
                .ticks(overviewAxisTicks.length)
            Severity: Major
            Found in js/plugins/overviewAxis.js and 1 other location - About 4 hrs to fix
            js/plugins/overviewAxis.js on lines 48..55

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

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

              var overviewAxis = d3.svg.axis().scale(xScaleOverview).orient("bottom")
                .tickFormat(function(d) { 
                  return timeline.formatTime(timeline.daysToTimeObject(d.valueOf()), originalZoomLevel);
                })
                .ticks(overviewAxisTicks.length)
            Severity: Major
            Found in js/plugins/overviewAxis.js and 1 other location - About 4 hrs to fix
            js/plugins/overviewAxis.js on lines 58..65

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

            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 run has 91 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            clinicalTimelineOverviewAxis.prototype.run = function(timeline, spec) {
              var readOnlyVars = timeline.getReadOnlyVars(),
                margin = readOnlyVars.margin,
                overviewAxisWidth = timeline.overviewAxisWidth(),
                chart = readOnlyVars.chart,
            Severity: Major
            Found in js/plugins/overviewAxis.js - About 3 hrs to fix

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

              var clinicalTimelineSanityChecker = (function() {
                function validateData(data) {
                  for (var i=0; i < data.length; i++) {
                    validateTrack(data[i]);
                  }
              Severity: Minor
              Found in js/sanity.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 run has 80 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              clinicalTimelineExporter.prototype.run = function(timeline, spec) {
                $(spec.exportDivId).css("visibility", "visible");
                return {
                  /**
                   * Exports the clinical-timeline as SVG
              Severity: Major
              Found in js/plugins/exportTimeline.js - About 3 hrs to fix

                Function addDataPointTooltip has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  timeline.addDataPointTooltip = function addDataPointTooltip(elem) {
                    function createDataTable(tooltip_table) {
                      var dataTable = {
                        "sDom": 't',
                        "bJQueryUI": true,
                Severity: Major
                Found in js/clinicalTimeline.js - About 3 hrs to fix

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

                      } else if (time.m !== 0) {
                        if (time.d !== 0) {
                          return time.m + "m" + Math.abs(time.d) + "d";
                        } else {
                          return time.m + "m";
                  Severity: Major
                  Found in js/clinicalTimeline.js and 1 other location - About 3 hrs to fix
                  js/clinicalTimeline.js on lines 448..456

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

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

                      if (time.y !== 0) {
                        if (time.m !== 0) {
                          return time.y + "y" + Math.abs(time.m) + "m";
                        } else {
                          return time.y + "y";
                  Severity: Major
                  Found in js/clinicalTimeline.js and 1 other location - About 3 hrs to fix
                  js/clinicalTimeline.js on lines 431..439

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

                  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 brushend has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var brushend = function() {
                        var extentStart = parseInt(d3.select(divId + " .extent").attr("x"));
                        var extentEnd = extentStart + parseInt(d3.select(divId+" .extent").attr("width"));
                        var zoomFactor, translate;
                        // if the zoom region is tiny, the user clicked instead of clicking
                  Severity: Major
                  Found in js/plugins/zoom.js - About 2 hrs to fix

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

                          var zoomBtn = d3.select(divId + " svg")
                            .insert("text")
                            .attr("transform", "translate("+(parseInt(svg.attr("width"))-70)+", "+parseInt(svg.attr("height")-5)+")")
                            .attr("class", "timeline-label")
                    Severity: Major
                    Found in js/plugins/zoom.js and 1 other location - About 2 hrs to fix
                    js/plugins/zoom.js on lines 178..181

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

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

                          d3.select(divId + " svg")
                            .insert("rect")
                            .attr("transform", "translate("+(parseInt(svg.attr("width"))-72)+", "+parseInt(svg.attr("height")-16)+")")
                            .attr("width", 68)
                    Severity: Major
                    Found in js/plugins/zoom.js and 1 other location - About 2 hrs to fix
                    js/plugins/zoom.js on lines 188..191

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

                    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 run has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    clinicalTimelineVerticalLine.prototype.run = function(timeline, spec) {
                      var divId = timeline.divId(),
                        hoverLineGroup = d3.select(divId + " svg").append("g")
                          .attr("class", "hover-line"),
                        hoverLine = hoverLineGroup
                    Severity: Major
                    Found in js/plugins/verticalLine.js - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language