meteor/meteor

View on GitHub
tools/meteor-services/auth.js

Summary

Maintainability
F
4 days
Test Coverage

File auth.js has 683 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var _ = require('underscore');
var utils = require('../utils/utils.js');
var files = require('../fs/files');
var config = require('./config.js');
var httpHelpers = require('../utils/http-helpers.js');
Severity: Major
Found in tools/meteor-services/auth.js - About 1 day to fix

    Function registerOrLogIn has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.registerOrLogIn = withAccountsConnection(function (connection) {
      var result;
      // Get their email
      while (true) {
        var email = Console.readLine({
    Severity: Major
    Found in tools/meteor-services/auth.js - About 3 hrs to fix

      Function doInteractivePasswordLogin has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      var doInteractivePasswordLogin = function (options) {
        var loginData = {};
      
        if (_.has(options, 'username')) {
          loginData.username = options.username;
      Severity: Minor
      Found in tools/meteor-services/auth.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 registerOrLogIn has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.registerOrLogIn = withAccountsConnection(function (connection) {
        var result;
        // Get their email
        while (true) {
          var email = Console.readLine({
      Severity: Minor
      Found in tools/meteor-services/auth.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 doInteractivePasswordLogin has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var doInteractivePasswordLogin = function (options) {
        var loginData = {};
      
        if (_.has(options, 'username')) {
          loginData.username = options.username;
      Severity: Major
      Found in tools/meteor-services/auth.js - About 2 hrs to fix

        Function tryRevokeOldTokens has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var tryRevokeOldTokens = function (options) {
          options = Object.assign({
            timeout: 5000
          }, options || {});
        
        
        Severity: Minor
        Found in tools/meteor-services/auth.js - About 1 hr to fix

          Function loginWithTokenOrOAuth has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.loginWithTokenOrOAuth = function (conn, accountsConfiguration,
                                                    url, domain, sessionType) {
            var setUpOnReconnect = function () {
              conn.onReconnect = function () {
                conn.apply('login', [{
          Severity: Minor
          Found in tools/meteor-services/auth.js - About 1 hr to fix

            Function pollForRegistrationCompletion has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.pollForRegistrationCompletion = function (options) {
              if (alreadyPolledForRegistration) {
                return;
              }
              alreadyPolledForRegistration = true;
            Severity: Minor
            Found in tools/meteor-services/auth.js - About 1 hr to fix

              Function sessionMethodCaller has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var sessionMethodCaller = function (methodName, options) {
                options = options || {};
                return function (...args) {
                  args.push({
                    session: auth.getSessionId(config.getAccountsDomain()) || null
              Severity: Minor
              Found in tools/meteor-services/auth.js - About 1 hr to fix

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

                var oauthFlow = function (conn, options) {
                  var crypto = require('crypto');
                  var credentialToken = crypto.randomBytes(16).toString('hex');
                
                  var authorizeResult = sendAuthorizeRequest(
                Severity: Minor
                Found in tools/meteor-services/auth.js - About 1 hr to fix

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

                  exports.maybePrintRegistrationLink = function (options) {
                    options = options || {};
                  
                    auth.pollForRegistrationCompletion();
                  
                  
                  Severity: Minor
                  Found in tools/meteor-services/auth.js - About 1 hr to fix

                    Function loginWithTokenOrOAuth has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.loginWithTokenOrOAuth = function (conn, accountsConfiguration,
                                                              url, domain, sessionType) {
                      var setUpOnReconnect = function () {
                        conn.onReconnect = function () {
                          conn.apply('login', [{
                    Severity: Minor
                    Found in tools/meteor-services/auth.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 loginCommand has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    exports.loginCommand = withAccountsConnection(function (options,
                                                                            connection) {
                      var data = readSessionData();
                    
                      if (! getSession(data, config.getAccountsDomain()).token ||
                    Severity: Minor
                    Found in tools/meteor-services/auth.js - About 1 hr to fix

                      Function maybePrintRegistrationLink has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      exports.maybePrintRegistrationLink = function (options) {
                        options = options || {};
                      
                        auth.pollForRegistrationCompletion();
                      
                      
                      Severity: Minor
                      Found in tools/meteor-services/auth.js - About 55 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 loginCommand has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      exports.loginCommand = withAccountsConnection(function (options,
                                                                              connection) {
                        var data = readSessionData();
                      
                        if (! getSession(data, config.getAccountsDomain()).token ||
                      Severity: Minor
                      Found in tools/meteor-services/auth.js - About 45 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 loginWithTokenOrOAuth has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      exports.loginWithTokenOrOAuth = function (conn, accountsConfiguration,
                                                                url, domain, sessionType) {
                      Severity: Minor
                      Found in tools/meteor-services/auth.js - About 35 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return loginResult;
                        Severity: Major
                        Found in tools/meteor-services/auth.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return false;
                          Severity: Major
                          Found in tools/meteor-services/auth.js - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status