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');
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({
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;
- Read upRead up
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({
- Read upRead up
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;
Function tryRevokeOldTokens
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
var tryRevokeOldTokens = function (options) {
options = Object.assign({
timeout: 5000
}, options || {});
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', [{
Function pollForRegistrationCompletion
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.pollForRegistrationCompletion = function (options) {
if (alreadyPolledForRegistration) {
return;
}
alreadyPolledForRegistration = true;
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
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(
Function maybePrintRegistrationLink
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.maybePrintRegistrationLink = function (options) {
options = options || {};
auth.pollForRegistrationCompletion();
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', [{
- Read upRead up
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 ||
Function maybePrintRegistrationLink
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
exports.maybePrintRegistrationLink = function (options) {
options = options || {};
auth.pollForRegistrationCompletion();
- Read upRead up
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 ||
- Read upRead up
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) {
Avoid too many return
statements within this function. Open
return loginResult;
Avoid too many return
statements within this function. Open
return false;