oaeproject/Hilary

View on GitHub
packages/oae-authentication/lib/api.js

Summary

Maintainability
C
7 hrs
Test Coverage
A
94%

Function getOrCreateUser has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  ctx,
  authProvider,
  externalId,
  providerProperties,
  displayName,
Severity: Major
Found in packages/oae-authentication/lib/api.js - About 50 mins to fix

    Function getOrCreateGlobalAdminUser has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      ctx,
      username,
      password,
      displayName,
      options,
    Severity: Minor
    Found in packages/oae-authentication/lib/api.js - About 45 mins to fix

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

      const _getOrCreateUser = function (ctx, loginId, displayName, options, callback) {
      Severity: Minor
      Found in packages/oae-authentication/lib/api.js - About 35 mins to fix

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

        const _createUser = function (ctx, loginId, displayName, options, callback) {
        Severity: Minor
        Found in packages/oae-authentication/lib/api.js - About 35 mins to fix

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

          const createTenantAdminUser = function (ctx, loginId, displayName, options, callback) {
          Severity: Minor
          Found in packages/oae-authentication/lib/api.js - About 35 mins to fix

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

            const changePassword = function (ctx, userId, oldPassword, newPassword, callback) {
            Severity: Minor
            Found in packages/oae-authentication/lib/api.js - About 35 mins to fix

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

              const createUser = function (ctx, loginId, displayName, options, callback) {
              Severity: Minor
              Found in packages/oae-authentication/lib/api.js - About 35 mins to fix

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

                const resetPassword = function (ctx, username, secret, newPassword, callback) {
                Severity: Minor
                Found in packages/oae-authentication/lib/api.js - About 35 mins to fix

                  Avoid too many return statements within this function.
                  Confirmed

                    return strategy.logout(request, response);
                  Severity: Major
                  Found in packages/oae-authentication/lib/api.js - About 30 mins to fix

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

                      try {
                        unless(isObject, {
                          code: 400,
                          msg: 'A LoginId must be provided'
                        })(loginId);
                    Severity: Major
                    Found in packages/oae-authentication/lib/api.js and 1 other location - About 2 hrs to fix
                    packages/oae-authentication/lib/api.js on lines 944..962

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

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

                      try {
                        unless(isNotEmpty, {
                          code: 401,
                          msg: 'A tenant must be provided'
                        })(tenantAlias);
                    Severity: Major
                    Found in packages/oae-authentication/lib/api.js and 1 other location - About 2 hrs to fix
                    packages/oae-authentication/lib/api.js on lines 540..558

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

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

                      try {
                        unless(isNotEmpty, {
                          code: 400,
                          msg: 'You must provide a display name'
                        })(displayName);
                    Severity: Major
                    Found in packages/oae-authentication/lib/api.js and 1 other location - About 2 hrs to fix
                    packages/oae-authentication/lib/api.js on lines 621..634

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

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

                      try {
                        unless(isNotEmpty, {
                          code: 400,
                          msg: 'You must provide a display name'
                        })(displayName);
                    Severity: Major
                    Found in packages/oae-authentication/lib/api.js and 1 other location - About 2 hrs to fix
                    packages/oae-authentication/lib/api.js on lines 338..352

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

                    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 5 locations. Consider refactoring.
                    Invalid

                      try {
                        unless(isLoggedInUser, {
                          code: 401,
                          msg: 'You have to be logged in to request the login ids for a user'
                        })(ctx);
                    Severity: Major
                    Found in packages/oae-authentication/lib/api.js and 4 other locations - About 1 hr to fix
                    packages/oae-content/lib/api.js on lines 1313..1325
                    packages/oae-content/lib/api.js on lines 1399..1411
                    packages/oae-content/lib/api.js on lines 2236..2248
                    packages/oae-principals/lib/api.terms-and-conditions.js on lines 74..86

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

                    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 4 locations. Consider refactoring.
                    Invalid

                    const {
                      validateInCase: bothCheck,
                      getNestedObject,
                      isLoggedInUser,
                      isGlobalAdministratorUser,
                    Severity: Major
                    Found in packages/oae-authentication/lib/api.js and 3 other locations - About 1 hr to fix
                    packages/oae-resource/lib/actions.js on lines 37..48
                    packages/oae-content/lib/model.js on lines 42..53
                    packages/oae-principals/lib/api.group.js on lines 44..55

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

                    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 (!ctx.user().isAdmin(user.tenant.alias)) {
                          // Only global administrators and administrators of the tenant the user belongs to can request the login ids
                          return callback({
                            code: 401,
                            msg: 'You are not authorized to request the login ids for this user'
                    Severity: Minor
                    Found in packages/oae-authentication/lib/api.js and 1 other location - About 50 mins to fix
                    packages/oae-authentication/lib/strategies/signed/util.js on lines 135..138

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

                    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

                        (error) => {
                          if (error) {
                            log().error({ err: error }, 'Error changing a user password');
                            return callback(error);
                          }
                    Severity: Minor
                    Found in packages/oae-authentication/lib/api.js and 1 other location - About 40 mins to fix
                    packages/oae-lti/lib/api.js on lines 271..283

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

                    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