meteor/meteor

View on GitHub
packages/accounts-base/accounts_client.js

Summary

Maintainability
F
4 days
Test Coverage

Function callLoginMethod has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

  callLoginMethod(options) {
    options = {
      methodName: 'login',
      methodArguments: [{}],
      _suppressLoggingIn: false,
Severity: Minor
Found in packages/accounts-base/accounts_client.js - About 1 day 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

File accounts_client.js has 410 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {AccountsCommon} from "./accounts_common.js";

/**
 * @summary Constructor for the `Accounts` object on the client.
 * @locus Client
Severity: Minor
Found in packages/accounts-base/accounts_client.js - About 5 hrs to fix

    AccountsClient has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class AccountsClient extends AccountsCommon {
      constructor(options) {
        super(options);
    
        this._loggingIn = new ReactiveVar(false);
    Severity: Minor
    Found in packages/accounts-base/accounts_client.js - About 4 hrs to fix

      Function callLoginMethod has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        callLoginMethod(options) {
          options = {
            methodName: 'login',
            methodArguments: [{}],
            _suppressLoggingIn: false,
      Severity: Major
      Found in packages/accounts-base/accounts_client.js - About 3 hrs to fix

        Function _initLocalStorage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _initLocalStorage() {
            // Key names to use in localStorage
            this.LOGIN_TOKEN_KEY = "Meteor.loginToken";
            this.LOGIN_TOKEN_EXPIRES_KEY = "Meteor.loginTokenExpires";
            this.USER_ID_KEY = "Meteor.userId";
        Severity: Minor
        Found in packages/accounts-base/accounts_client.js - About 1 hr to fix

          Function onResultReceived has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const onResultReceived = (err, result) => {
                if (err || !result || !result.token) {
                  // Leave onReconnect alone if there was an error, so that if the user was
                  // already logged in they will still get logged in on reconnect.
                  // See issue #4970.
          Severity: Minor
          Found in packages/accounts-base/accounts_client.js - About 1 hr to fix

            Function _reconnectStopper has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    this._reconnectStopper = DDP.onReconnect(conn => {
                      if (conn != this.connection) {
                        return;
                      }
                      reconnected = true;
            Severity: Minor
            Found in packages/accounts-base/accounts_client.js - About 1 hr to fix

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

                _initLocalStorage() {
                  // Key names to use in localStorage
                  this.LOGIN_TOKEN_KEY = "Meteor.loginToken";
                  this.LOGIN_TOKEN_EXPIRES_KEY = "Meteor.loginTokenExpires";
                  this.USER_ID_KEY = "Meteor.userId";
              Severity: Minor
              Found in packages/accounts-base/accounts_client.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 attemptToMatchHash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              const attemptToMatchHash = (accounts, hash, success) => {
                // All of the special hash URLs we support for accounts interactions
                ["reset-password", "verify-email", "enroll-account"].forEach(urlPart => {
                  let token;
              
              
              Severity: Minor
              Found in packages/accounts-base/accounts_client.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

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

                callLoginFunction(funcName, ...funcArgs) {
                  if (!this._loginFuncs[funcName]) {
                    throw new Error(`${funcName} was not defined`);
                  }
                  return this._loginFuncs[funcName].apply(this, funcArgs);
              Severity: Major
              Found in packages/accounts-base/accounts_client.js and 1 other location - About 1 hr to fix
              packages/accounts-base/accounts_client.js on lines 108..113

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

              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

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

                applyLoginFunction(funcName, funcArgs) {
                  if (!this._loginFuncs[funcName]) {
                    throw new Error(`${funcName} was not defined`);
                  }
                  return this._loginFuncs[funcName].apply(this, funcArgs);
              Severity: Major
              Found in packages/accounts-base/accounts_client.js and 1 other location - About 1 hr to fix
              packages/accounts-base/accounts_client.js on lines 94..99

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

              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 3 locations. Consider refactoring.
              Open

                onEnrollmentLink(callback) {
                  if (this._accountsCallbacks["enroll-account"]) {
                    Meteor._debug("Accounts.onEnrollmentLink was called more than once. " +
                      "Only one callback added will be executed.");
                  }
              Severity: Major
              Found in packages/accounts-base/accounts_client.js and 2 other locations - About 1 hr to fix
              packages/accounts-base/accounts_client.js on lines 675..682
              packages/accounts-base/accounts_client.js on lines 702..709

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

              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 3 locations. Consider refactoring.
              Open

                onEmailVerificationLink(callback) {
                  if (this._accountsCallbacks["verify-email"]) {
                    Meteor._debug("Accounts.onEmailVerificationLink was called more than once. " +
                      "Only one callback added will be executed.");
                  }
              Severity: Major
              Found in packages/accounts-base/accounts_client.js and 2 other locations - About 1 hr to fix
              packages/accounts-base/accounts_client.js on lines 675..682
              packages/accounts-base/accounts_client.js on lines 729..736

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

              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 3 locations. Consider refactoring.
              Open

                onResetPasswordLink(callback) {
                  if (this._accountsCallbacks["reset-password"]) {
                    Meteor._debug("Accounts.onResetPasswordLink was called more than once. " +
                      "Only one callback added will be executed.");
                  }
              Severity: Major
              Found in packages/accounts-base/accounts_client.js and 2 other locations - About 1 hr to fix
              packages/accounts-base/accounts_client.js on lines 702..709
              packages/accounts-base/accounts_client.js on lines 729..736

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

              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