cBioPortal/clinical-timeline

View on GitHub

Showing 38 of 92 total issues

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

clinicalTimelineExporter.prototype.run = function(timeline, spec) {
  $(spec.exportDivId).css("visibility", "visible");
  return {
    /**
     * Exports the clinical-timeline as SVG
Severity: Minor
Found in js/plugins/exportTimeline.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 addNewTrackTooltip has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function addNewTrackTooltip(elem) {
    elem.qtip({
    content: {
      text: 'addtrack'
    },
Severity: Minor
Found in js/clinicalTimeline.js - About 1 hr to fix

    Function generatePNG has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        generatePNG : function(download) {
          $("#addtrack").css("visibility","hidden");
          var element = document.getElementsByTagName('path')[0];
          element.setAttribute("stroke" , "black"); 
          element.setAttribute("fill" , "none");
    Severity: Minor
    Found in js/plugins/exportTimeline.js - About 1 hr to fix

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

              render: function(event, api) {
                var trackTooltip = $.parseHTML("<div class='track-toolip'></div>");
                var a = $.parseHTML("<a href='#' onClick='return false' class='hide-track'>Hide " +
                  elem.prop("innerHTML") + "</a>");
                $(a).on("click", hideTrackClickHandler(elem.prop("innerHTML")));
      Severity: Minor
      Found in js/clinicalTimeline.js - About 1 hr to fix

        Function getTickValues has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          timeline.getTickValues = function (minDays, maxDays, zoomLevel) {
              var tickValues = [],
                maxTime = timeline.daysToTimeObject(parseInt(maxDays)),
                minTime = timeline.daysToTimeObject(parseInt(minDays)),
                roundDown = clinicalTimelineUtil.roundDown,
        Severity: Minor
        Found in js/clinicalTimeline.js - About 1 hr to fix

          Function run has a Cognitive Complexity of 10 (exceeds 5 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: Minor
          Found in js/plugins/trimTimeline.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 render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  render: function(event, api) {
                    var tooltipDiv = $.parseHTML("<div></div>"),
                      d = elem.prop("__data__"), table;
                    if ("tooltip_tables" in d) {
                      for (var i=0; i < d.tooltip_tables.length; i++) {
          Severity: Minor
          Found in js/clinicalTimeline.js - About 1 hr to fix

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

              function transformToTimelineJSON(clinical_timeline_data) {
                var transformToTrack = function(clin_events) {
                  var track = {
                    "label":transformLabel(clin_events[0].eventType),
                    visible:true,
            Severity: Minor
            Found in js/parser.js - About 1 hr to fix

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

                  generateSVG :  function () {
                    $("#addtrack").css("visibility","hidden");
                    var element = document.getElementsByTagName('path')[0];
                    element.setAttribute("stroke" , "black"); 
                    element.setAttribute("fill" , "none");
              Severity: Minor
              Found in js/plugins/exportTimeline.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                          for (i=minTime.toDays(); i <= maxTime.toDays(); i++) {
                              tickValues.push(i);
                          }
                Severity: Major
                Found in js/clinicalTimeline.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            for (i=roundDown(minTime.toDays(), 3); i <= roundUp(maxTime.toDays(), 3); i+=3) {
                                tickValues.push(i);
                            }
                  Severity: Major
                  Found in js/clinicalTimeline.js - About 45 mins to fix

                    Function zoomExplanation has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      function zoomExplanation(divId, svg, text, visibility, pos) {
                    Severity: Minor
                    Found in js/plugins/zoom.js - About 35 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return time.m + "m" + Math.abs(time.d) + "d";
                      Severity: Major
                      Found in js/clinicalTimeline.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return time.d + "d";
                        Severity: Major
                        Found in js/clinicalTimeline.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                return "days";
                          Severity: Major
                          Found in js/clinicalTimeline.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return time.m + "m";
                            Severity: Major
                            Found in js/clinicalTimeline.js - About 30 mins to fix

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

                                roundDown : function(numToRound, multiple) {
                                  var remainder = numToRound % multiple;
                                  if (multiple === 0 || remainder === 0) {
                                    return numToRound;
                                  } else{
                              Severity: Minor
                              Found in js/plugins/util.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

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

                                roundUp : function(numToRound, multiple) {
                                  var remainder = numToRound % multiple;
                                  if (multiple === 0 || remainder === 0) {
                                    return numToRound;
                                  } else{
                              Severity: Minor
                              Found in js/plugins/util.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

                              Severity
                              Category
                              Status
                              Source
                              Language