QuickBlox/quickblox-javascript-sdk

View on GitHub
src/qbMain.js

Summary

Maintainability
C
1 day
Test Coverage

Function init has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    init: function(appIdOrToken, authKeyOrAppId, authSecret, accountKey, configMap) {
        console.log('current platform: ', Utils.getEnv());
        if (typeof accountKey === 'string' && accountKey.length) {
            if (configMap && typeof configMap === 'object') {
                config.set(configMap);
Severity: Major
Found in src/qbMain.js - About 3 hrs to fix

    Function init has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        init: function(appIdOrToken, authKeyOrAppId, authSecret, accountKey, configMap) {
            console.log('current platform: ', Utils.getEnv());
            if (typeof accountKey === 'string' && accountKey.length) {
                if (configMap && typeof configMap === 'object') {
                    config.set(configMap);
    Severity: Minor
    Found in src/qbMain.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 startSessionWithToken has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        startSessionWithToken: function(token, callback) {
            if (token === undefined) throw new Error('Cannot start session with undefined token');
            else if (token === '') throw new Error('Cannot start session with empty string token');
            else if (token === null) throw new Error('Cannot start session with null value token');
            else if (typeof callback !== 'function') throw new Error('Cannot start session without callback function');
    Severity: Minor
    Found in src/qbMain.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

    Consider simplifying this complex logical expression.
    Open

            if (appId === '' || appId === undefined || appId === null ||
                accountKey === '' || accountKey === undefined || accountKey === null) {
                throw new Error('Cannot init QuickBlox without app credentials (app ID, auth key)');
            } else {
                this.init('', appId, null, accountKey, configMap);
    Severity: Major
    Found in src/qbMain.js - About 40 mins to fix

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

          init: function(appIdOrToken, authKeyOrAppId, authSecret, accountKey, configMap) {
      Severity: Minor
      Found in src/qbMain.js - About 35 mins to fix

        Unexpected console statement.
        Open

                console.log('current platform: ', Utils.getEnv());
        Severity: Minor
        Found in src/qbMain.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.warn('NOTE: Account migration will not work without "accountKey"');
        Severity: Minor
        Found in src/qbMain.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.warn('Parameter "accountKey" is missing. This will lead to error in next major release');
        Severity: Minor
        Found in src/qbMain.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

        There are no issues that match your filters.

        Category
        Status