QuickBlox/quickblox-javascript-sdk

View on GitHub
src/qbUtils.js

Summary

Maintainability
D
2 days
Test Coverage

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

    QBLog: function(){
        if (this.loggers) {
            for (var i=0; i<this.loggers.length; ++i) {
                this.loggers[i](arguments);
            }
Severity: Minor
Found in src/qbUtils.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 QBLog has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    QBLog: function(){
        if (this.loggers) {
            for (var i=0; i<this.loggers.length; ++i) {
                this.loggers[i](arguments);
            }
Severity: Major
Found in src/qbUtils.js - About 2 hrs to fix

    File qbUtils.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint no-console: 2 */
    
    'use strict';
    
    var config = require('./qbConfig');
    Severity: Minor
    Found in src/qbUtils.js - About 2 hrs to fix

      Function injectISOTimes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          injectISOTimes: function(data) {
              if (data.created_at) {
                  if (typeof data.created_at === 'number') data.iso_created_at = new Date(data.created_at * 1000).toISOString();
                  if (typeof data.updated_at === 'number') data.iso_updated_at = new Date(data.updated_at * 1000).toISOString();
              }
      Severity: Minor
      Found in src/qbUtils.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 getOS has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getOS: function() {
              var self = this;
              var osName = 'An unknown OS';
      
              var OS_LIST = [
      Severity: Minor
      Found in src/qbUtils.js - About 1 hr to fix

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

            getError: function(code, detail, moduleName) {
                var errorMsg = {
                    code: code,
                    status: 'error',
                    detail: detail
        Severity: Minor
        Found in src/qbUtils.js - About 1 hr to fix

          Function MergeArrayOfObjects has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              MergeArrayOfObjects: function (arrayTo, arrayFrom){
                  var merged = JSON.parse(JSON.stringify(arrayTo));
          
                  firstLevel: for(var i = 0; i < arrayFrom.length; i++){
                      var newItem = arrayFrom[i];
          Severity: Minor
          Found in src/qbUtils.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

          Unexpected console statement.
          Open

                          console.error('Error in listener ' + listenerName + ': ' + err);
          Severity: Minor
          Found in src/qbUtils.js by eslint

          disallow the use of console (no-console)

          In JavaScript that is designed to be executed in the browser, it's considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using console should be stripped before being pushed to production.

          console.log("Made it here.");
          console.error("That shouldn't have happened.");

          Rule Details

          This rule disallows calls to methods of the console object.

          Examples of incorrect code for this rule:

          /*eslint no-console: "error"*/
          
          console.log("Log a debug level message.");
          console.warn("Log a warn level message.");
          console.error("Log an error level message.");

          Examples of correct code for this rule:

          /*eslint no-console: "error"*/
          
          // custom console
          Console.log("Hello world!");

          Options

          This rule has an object option for exceptions:

          • "allow" has an array of strings which are allowed methods of the console object

          Examples of additional correct code for this rule with a sample { "allow": ["warn", "error"] } option:

          /*eslint no-console: ["error", { allow: ["warn", "error"] }] */
          
          console.warn("Log a warn level message.");
          console.error("Log an error level message.");

          When Not To Use It

          If you're using Node.js, however, console is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.

          Related Rules

          Unexpected console statement.
          Open

                          console.log.apply(console, Array.prototype.slice.call(args));
          Severity: Minor
          Found in src/qbUtils.js by eslint

          disallow the use of console (no-console)

          In JavaScript that is designed to be executed in the browser, it's considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using console should be stripped before being pushed to production.

          console.log("Made it here.");
          console.error("That shouldn't have happened.");

          Rule Details

          This rule disallows calls to methods of the console object.

          Examples of incorrect code for this rule:

          /*eslint no-console: "error"*/
          
          console.log("Log a debug level message.");
          console.warn("Log a warn level message.");
          console.error("Log an error level message.");

          Examples of correct code for this rule:

          /*eslint no-console: "error"*/
          
          // custom console
          Console.log("Hello world!");

          Options

          This rule has an object option for exceptions:

          • "allow" has an array of strings which are allowed methods of the console object

          Examples of additional correct code for this rule with a sample { "allow": ["warn", "error"] } option:

          /*eslint no-console: ["error", { allow: ["warn", "error"] }] */
          
          console.warn("Log a warn level message.");
          console.error("Log an error level message.");

          When Not To Use It

          If you're using Node.js, however, console is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.

          Related Rules

          Unexpected console statement.
          Open

                                      return console.error('Error while writing log to file. Error: ' + err);
          Severity: Minor
          Found in src/qbUtils.js by eslint

          disallow the use of console (no-console)

          In JavaScript that is designed to be executed in the browser, it's considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using console should be stripped before being pushed to production.

          console.log("Made it here.");
          console.error("That shouldn't have happened.");

          Rule Details

          This rule disallows calls to methods of the console object.

          Examples of incorrect code for this rule:

          /*eslint no-console: "error"*/
          
          console.log("Log a debug level message.");
          console.warn("Log a warn level message.");
          console.error("Log an error level message.");

          Examples of correct code for this rule:

          /*eslint no-console: "error"*/
          
          // custom console
          Console.log("Hello world!");

          Options

          This rule has an object option for exceptions:

          • "allow" has an array of strings which are allowed methods of the console object

          Examples of additional correct code for this rule with a sample { "allow": ["warn", "error"] } option:

          /*eslint no-console: ["error", { allow: ["warn", "error"] }] */
          
          console.warn("Log a warn level message.");
          console.error("Log an error level message.");

          When Not To Use It

          If you're using Node.js, however, console is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.

          Related Rules

          Unexpected console statement.
          Open

                          console.error('Error: ' + err);
          Severity: Minor
          Found in src/qbUtils.js by eslint

          disallow the use of console (no-console)

          In JavaScript that is designed to be executed in the browser, it's considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using console should be stripped before being pushed to production.

          console.log("Made it here.");
          console.error("That shouldn't have happened.");

          Rule Details

          This rule disallows calls to methods of the console object.

          Examples of incorrect code for this rule:

          /*eslint no-console: "error"*/
          
          console.log("Log a debug level message.");
          console.warn("Log a warn level message.");
          console.error("Log an error level message.");

          Examples of correct code for this rule:

          /*eslint no-console: "error"*/
          
          // custom console
          Console.log("Hello world!");

          Options

          This rule has an object option for exceptions:

          • "allow" has an array of strings which are allowed methods of the console object

          Examples of additional correct code for this rule with a sample { "allow": ["warn", "error"] } option:

          /*eslint no-console: ["error", { allow: ["warn", "error"] }] */
          
          console.warn("Log a warn level message.");
          console.error("Log an error level message.");

          When Not To Use It

          If you're using Node.js, however, console is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.

          Related Rules

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

                          if (typeof data.items[i].created_at === 'number') data.items[i].iso_created_at = new Date(data.items[i].created_at * 1000).toISOString();
          Severity: Major
          Found in src/qbUtils.js and 1 other location - About 1 hr to fix
          src/qbUtils.js on lines 162..162

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

          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 (typeof data.items[i].updated_at === 'number') data.items[i].iso_updated_at = new Date(data.items[i].updated_at * 1000).toISOString();
          Severity: Major
          Found in src/qbUtils.js and 1 other location - About 1 hr to fix
          src/qbUtils.js on lines 161..161

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

          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

                      for(var j=0;j<this.loggers.length;++j){
                          this.loggers[j](arguments);
                      }
          Severity: Minor
          Found in src/qbUtils.js and 1 other location - About 35 mins to fix
          src/qbUtils.js on lines 170..172

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

          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

                      for (var i=0; i<this.loggers.length; ++i) {
                          this.loggers[i](arguments);
                      }
          Severity: Minor
          Found in src/qbUtils.js and 1 other location - About 35 mins to fix
          src/qbUtils.js on lines 251..253

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

          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

          There are no issues that match your filters.

          Category
          Status