cBioPortal/iViz

View on GitHub
app/scripts/views/components/survivalChart/main.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function Survival has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  iViz.view.component.Survival = function() {
    var content_ = this;
    var opts_ = {
      downloadIsEnabled: true
    };
Severity: Major
Found in app/scripts/views/components/survivalChart/main.js - About 2 hrs to fix

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

        content_.update = function(groups, _chartId, _attrId) {
          // remove previous curves
          var _chartInst_ = this.chartInst_;
          var _newGroups = [];
          _chartInst_.removeCurves();
    Severity: Minor
    Found in app/scripts/views/components/survivalChart/main.js - About 1 hr to fix

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

          function initCanvasDownloadData() {
            content_.setDownloadData('svg', {
              title: opts_.title,
              chartDivId: opts_.chartId,
              fileName: opts_.title
      Severity: Major
      Found in app/scripts/views/components/survivalChart/main.js and 1 other location - About 2 hrs to fix
      app/scripts/views/components/scatterPlot/scatterPlot.js on lines 210..221

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

      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

      Missing JSDoc comment.
      Open

          function initCanvasDownloadData() {

      Require JSDoc comment (require-jsdoc)

      JSDoc is a JavaScript API documentation generator. It uses specially-formatted comments inside of code to generate API documentation automatically. For example, this is what a JSDoc comment looks like for a function:

      /**
       * Adds two numbers together.
       * @param {int} num1 The first number.
       * @param {int} num2 The second number.
       * @returns {int} The sum of the two numbers.
       */
      function sum(num1, num2) {
          return num1 + num2;
      }

      Some style guides require JSDoc comments for all functions as a way of explaining function behavior.

      Rule Details

      This rule generates warnings for nodes that do not have JSDoc comments when they should. Supported nodes:

      • FunctionDeclaration
      • ClassDeclaration
      • MethodDefinition

      Options

      This rule accepts a require object with its properties as

      • FunctionDeclaration (default: true)
      • ClassDeclaration (default: false)
      • MethodDefinition (default: false)

      Default option settings are

      {
          "require-jsdoc": ["error", {
              "require": {
                  "FunctionDeclaration": true,
                  "MethodDefinition": false,
                  "ClassDeclaration": false
              }
          }]
      }

      The following patterns are considered problems:

      /*eslint "require-jsdoc": ["error", {
          "require": {
              "FunctionDeclaration": true,
              "MethodDefinition": true,
              "ClassDeclaration": true
          }
      }]*/
      
      function foo() {
          return 10;
      }
      
      class Test{
          getDate(){}
      }

      The following patterns are not considered problems:

      /*eslint "require-jsdoc": ["error", {
          "require": {
              "FunctionDeclaration": true,
              "MethodDefinition": true,
              "ClassDeclaration": true
          }
      }]*/
      
      /**
      * It returns 10
      */
      function foo() {
          return 10;
      }
      
      /**
      * It returns 10
      */
      var foo = function() {
          return 10;
      }
      
      var array = [1,2,3];
      array.filter(function(item) {
          return item > 2;
      });
      
      /**
      * It returns 10
      */
      class Test{
          /**
          * returns the date
          */
          getDate(){}
      }

      When Not To Use It

      If you do not require JSDoc for your functions, then you can leave this rule off.

      Related Rules

      Line 46 exceeds the maximum line length of 80.
      Open

                  _chartInst_.addPval(_newGroups[0].proxyData, _newGroups[1].proxyData);

      enforce a maximum line length (max-len)

      Very long lines of code in any language can be difficult to read. In order to aid in readability and maintainability many coders have developed a convention to limit lines of code to X number of characters (traditionally 80 characters).

      var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; // very long

      Rule Details

      This rule enforces a maximum line length to increase code readability and maintainability.

      Note: This rule calculates the length of a line via code points, not characters. That means if you use a double-byte character in your code, it will count as 2 code points instead of 1, and 2 will be used to calculate line length. This is a technical limitation of JavaScript that is made easier with ES2015, and we will look to update this when ES2015 is available in Node.js.

      Options

      This rule has a number or object option:

      • "code" (default 80) enforces a maximum line length
      • "tabWidth" (default 4) specifies the character width for tab characters
      • "comments" enforces a maximum line length for comments; defaults to value of code
      • "ignorePattern" ignores lines matching a regular expression; can only match a single line and need to be double escaped when written in YAML or JSON
      • "ignoreComments": true ignores all trailing comments and comments on their own line
      • "ignoreTrailingComments": true ignores only trailing comments
      • "ignoreUrls": true ignores lines that contain a URL

      code

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

      /*eslint max-len: ["error", 80]*/
      
      var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" };

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

      /*eslint max-len: ["error", 80]*/
      
      var foo = {
        "bar": "This is a bar.",
        "baz": { "qux": "This is a qux" },
        "easier": "to read"
      };

      tabWidth

      Examples of incorrect code for this rule with the default { "tabWidth": 4 } option:

      /*eslint max-len: ["error", 80, 4]*/
      
      \t  \t  var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };

      Examples of correct code for this rule with the default { "tabWidth": 4 } option:

      /*eslint max-len: ["error", 80, 4]*/
      
      \t  \t  var foo = {
      \t  \t  \t  \t  "bar": "This is a bar.",
      \t  \t  \t  \t  "baz": { "qux": "This is a qux" }
      \t  \t  };

      comments

      Examples of incorrect code for this rule with the { "comments": 65 } option:

      /*eslint max-len: ["error", { "comments": 65 }]*/
      
      /**
       * This is a comment that violates the maximum line length we have specified
      **/

      ignoreComments

      Examples of correct code for this rule with the { "ignoreComments": true } option:

      /*eslint max-len: ["error", { "ignoreComments": true }]*/
      
      /**
       * This is a really really really really really really really really really long comment
      **/

      ignoreTrailingComments

      Examples of correct code for this rule with the { "ignoreTrailingComments": true } option:

      /*eslint max-len: ["error", { "ignoreTrailingComments": true }]*/
      
      var foo = 'bar'; // This is a really really really really really really really long comment

      ignoreUrls

      Examples of correct code for this rule with the { "ignoreUrls": true } option:

      /*eslint max-len: ["error", { "ignoreUrls": true }]*/
      
      var url = 'https://www.example.com/really/really/really/really/really/really/really/long';

      ignorePattern

      Examples of correct code for this rule with the { "ignorePattern": true } option:

      /*eslint max-len: ["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(/" }]*/
      
      var dep = require('really/really/really/really/really/really/really/really/long/module');

      Related Rules

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

      Trailing spaces not allowed.
      Open

          

      Disallow trailing spaces at the end of lines (no-trailing-spaces)

      (fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

      Sometimes in the course of editing files, you can end up with extra whitespace at the end of lines. These whitespace differences can be picked up by source control systems and flagged as diffs, causing frustration for developers. While this extra whitespace causes no functional issues, many code conventions require that trailing spaces be removed before checkin.

      Rule Details

      The following patterns are considered problems:

      /*eslint no-trailing-spaces: "error"*/
      
      // spaces, tabs and unicode whitespaces
      // are not allowed at the end of lines
      var foo = 0;//•••••
      var baz = 5;//••

      The following patterns are not considered problems:

      /*eslint no-trailing-spaces: "error"*/
      
      var foo = 0;
      
      var baz = 5;

      Options

      There is one option for this rule, skipBlankLines. When set to true, the rule will not flag any lines that are made up purely of whitespace. In short, if a line is zero-length after being trimmed of whitespace, then the rule will not flag that line when skipBlankLines is enabled.

      You can enable this option in your config like this:

      {
          "no-trailing-spaces": ["error", { "skipBlankLines": true }]
      }

      With this option enabled, The following patterns are not considered problems:

      /*eslint no-trailing-spaces: ["error", { "skipBlankLines": true }]*/
      
      var foo = 0;
      //••••
      var baz = 5;

      Source: http://eslint.org/docs/rules/

      Expected space(s) after "if".
      Open

                if(_.isArray(group.proxyData) && group.proxyData.length > 0) {

      enforce consistent spacing before and after keywords (keyword-spacing)

      (fixable) The --fix option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

      Keywords are syntax elements of JavaScript, such as function and if. These identifiers have special meaning to the language and so often appear in a different color in code editors. As an important part of the language, style guides often refer to the spacing that should be used around keywords. For example, you might have a style guide that says keywords should be always surrounded by spaces, which would mean if-else statements must look like this:

      if (foo) {
          // ...
      } else {
          // ...
      }

      Of course, you could also have a style guide that disallows spaces around keywords.

      Rule Details

      This rule enforces consistent spacing around keywords and keyword-like tokens: as (in module declarations), break, case, catch, class, const, continue, debugger, default, delete, do, else, export, extends, finally, for, from (in module declarations), function, get (of getters), if, import, in, instanceof, let, new, of (in for-of statements), return, set (of setters), static, super, switch, this, throw, try, typeof, var, void, while, with, and yield. This rule is designed carefully not to conflict with other spacing rules: it does not apply to spacing where other rules report problems.

      Options

      This rule has an object option:

      • "before": true (default) requires at least one space before keywords
      • "before": false disallows spaces before keywords
      • "after": true (default) requires at least one space after keywords
      • "after": false disallows spaces after keywords
      • "overrides" allows overriding spacing style for specified keywords

      before

      Examples of incorrect code for this rule with the default { "before": true } option:

      /*eslint keyword-spacing: ["error", { "before": true }]*/
      
      if (foo) {
          //...
      }else if (bar) {
          //...
      }else {
          //...
      }

      Examples of correct code for this rule with the default { "before": true } option:

      /*eslint keyword-spacing: ["error", { "before": true }]*/
      /*eslint-env es6*/
      
      if (foo) {
          //...
      } else if (bar) {
          //...
      } else {
          //...
      }
      
      // no conflict with `array-bracket-spacing`
      let a = [this];
      let b = [function() {}];
      
      // no conflict with `arrow-spacing`
      let a = ()=> this.foo;
      
      // no conflict with `block-spacing`
      {function foo() {}}
      
      // no conflict with `comma-spacing`
      let a = [100,this.foo, this.bar];
      
      // not conflict with `computed-property-spacing`
      obj[this.foo] = 0;
      
      // no conflict with `generator-star-spacing`
      function *foo() {}
      
      // no conflict with `key-spacing`
      let obj = {
          foo:function() {}
      };
      
      // no conflict with `object-curly-spacing`
      let obj = {foo: this};
      
      // no conflict with `semi-spacing`
      let a = this;function foo() {}
      
      // no conflict with `space-in-parens`
      (function () {})();
      
      // no conflict with `space-infix-ops`
      if ("foo"in {foo: 0}) {}
      if (10+this.foo<= this.bar) {}
      
      // no conflict with `jsx-curly-spacing`
      let a = 

      Examples of incorrect code for this rule with the { "before": false } option:

      /*eslint keyword-spacing: ["error", { "before": false }]*/
      
      if (foo) {
          //...
      } else if (bar) {
          //...
      } else {
          //...
      }

      Examples of correct code for this rule with the { "before": false } option:

      /*eslint keyword-spacing: ["error", { "before": false }]*/
      
      if (foo) {
          //...
      }else if (bar) {
          //...
      }else {
          //...
      }

      after

      Examples of incorrect code for this rule with the default { "after": true } option:

      /*eslint keyword-spacing: ["error", { "after": true }]*/
      
      if(foo) {
          //...
      } else if(bar) {
          //...
      } else{
          //...
      }

      Examples of correct code for this rule with the default { "after": true } option:

      /*eslint keyword-spacing: ["error", { "after": true }]*/
      
      if (foo) {
          //...
      } else if (bar) {
          //...
      } else {
          //...
      }
      
      // not conflict with `array-bracket-spacing`
      let a = [this];
      
      // not conflict with `arrow-spacing`
      let a = ()=> this.foo;
      
      // not conflict with `comma-spacing`
      let a = [100, this.foo, this.bar];
      
      // not conflict with `computed-property-spacing`
      obj[this.foo] = 0;
      
      // not conflict with `generator-star-spacing`
      function* foo() {}
      
      // not conflict with `key-spacing`
      let obj = {
          foo:function() {}
      };
      
      // not conflict with `no-spaced-func`
      class A {
          constructor() {
              super();
          }
      }
      
      // not conflict with `object-curly-spacing`
      let obj = {foo: this};
      
      // not conflict with `semi-spacing`
      let a = this;function foo() {}
      
      // not conflict with `space-before-function-paren`
      function() {}
      
      // no conflict with `space-infix-ops`
      if ("foo"in{foo: 0}) {}
      if (10+this.foo<= this.bar) {}
      
      // no conflict with `space-unary-ops`
      function* foo(a) {
          return yield+a;
      }
      
      // no conflict with `yield-star-spacing`
      function* foo(a) {
          return yield* a;
      }
      
      // no conflict with `jsx-curly-spacing`
      let a = 

      Examples of incorrect code for this rule with the { "after": false } option:

      /*eslint keyword-spacing: ["error", { "after": false }]*/
      
      if (foo) {
          //...
      } else if (bar) {
          //...
      } else {
          //...
      }

      Examples of correct code for this rule with the { "after": false } option:

      /*eslint keyword-spacing: ["error", { "after": false }]*/
      
      if(foo) {
          //...
      } else if(bar) {
          //...
      } else{
          //...
      }

      overrides

      Examples of correct code for this rule with the { "overrides": { "if": { "after": false }, "for": { "after": false }, "while": { "after": false } } } option:

      /*eslint keyword-spacing: ["error", { "overrides": {
        "if": { "after": false },
        "for": { "after": false },
        "while": { "after": false }
      } }]*/
      
      if(foo) {
          //...
      } else if(bar) {
          //...
      } else {
          //...
      }
      
      for(;;);
      
      while(true) {
        //...
      }

      When Not To Use It

      If you don't want to enforce consistency on keyword spacing, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

      Block must not be padded by blank lines.
      Open

            if (_.isArray(groups)) {

      Enforce padding within blocks (padded-blocks)

      Some style guides require block statements to start and end with blank lines. The goal is to improve readability by visually separating the block content and the surrounding code.

      if (a) {
      
          b();
      
      }

      Since it's good to have a consistent code style, you should either always write padded blocks or never do it.

      Rule Details

      This rule enforces consistent padding within blocks.

      This rule takes one argument, which can be an string or an object. If it is "always" (the default) then block statements must start and end with a blank line. If "never", then block statements should neither start nor end with a blank line. By default, this rule ignores padding in switch statements and classes.

      If you want to enforce padding within switches and classes, a configuration object can be passed as the rule argument to configure the cases separately ( e.g. { "blocks": "always", "switches": "always", "classes": "always" } ).

      The following patterns are considered problems when set to "always":

      /*eslint padded-blocks: ["error", "always"]*/
      
      if (a) {
          b();
      }
      
      if (a) { b(); }
      
      if (a)
      {
          b();
      }
      
      if (a) {
      
          b();
      }
      
      if (a) {
          b();
      
      }
      
      if (a) {
          // comment
          b();
      
      }

      The following patterns are not considered problems when set to "always":

      /*eslint padded-blocks: ["error", "always"]*/
      
      if (a) {
      
          b();
      
      }
      
      if (a)
      {
      
          b();
      
      }
      
      if (a) {
      
          // comment
          b();
      
      }

      The following patterns are considered problems when set to "never":

      /*eslint padded-blocks: ["error", "never"]*/
      
      if (a) {
      
          b();
      
      }
      
      if (a)
      {
      
          b();
      
      }
      
      if (a) {
      
          b();
      }
      
      if (a) {
          b();
      
      }

      The following patterns are not considered problems when set to "never":

      /*eslint padded-blocks: ["error", "never"]*/
      
      if (a) {
          b();
      }
      
      if (a)
      {
          b();
      }

      The following patterns are considered problems when configured { "switches": "always" }:

      /*eslint padded-blocks: ["error", { "switches": "always" }]*/
      
      switch (a) {
          case 0: foo();
      }

      The following patterns are not considered problems when configured { "switches": "always" }:

      /*eslint padded-blocks: ["error", { "switches": "always" }]*/
      
      switch (a) {
      
          case 0: foo();
      
      }
      
      if (a) {
          b();
      }

      The following patterns are considered problems when configured { "switches": "never" }:

      /*eslint padded-blocks: ["error", { "switches": "never" }]*/
      
      switch (a) {
      
          case 0: foo();
      
      }

      The following patterns are not considered problems when configured { "switches": "never" }:

      /*eslint padded-blocks: ["error", { "switches": "never" }]*/
      
      switch (a) {
          case 0: foo();
      }
      
      if (a) {
      
          b();
      
      }

      The following patterns are considered problems when configured { "classes": "always" }:

      /*eslint padded-blocks: ["error", { "classes": "always" }]*/
      
      class  A {
          constructor(){
          }
      }

      The following patterns are not considered problems when configured { "classes": "always" }:

      /*eslint padded-blocks: ["error", { "classes": "always" }]*/
      
      class  A {
      
          constructor(){
          }
      
      }

      The following patterns are considered problems when configured { "classes": "never" }:

      /*eslint padded-blocks: ["error", { "classes": "never" }]*/
      
      class  A {
      
          constructor(){
          }
      
      }

      The following patterns are not considered problems when configured { "classes": "never" }:

      /*eslint padded-blocks: ["error", { "classes": "never" }]*/
      
      class  A {
          constructor(){
          }
      }

      When Not To Use It

      You can turn this rule off if you are not concerned with the consistency of padding within blocks. Source: http://eslint.org/docs/rules/

      There are no issues that match your filters.

      Category
      Status