oaeproject/Hilary

View on GitHub
packages/oae-principals/lib/rest.user.js

Summary

Maintainability
F
5 days
Test Coverage
A
97%

Avoid too many return statements within this function.
Open

    return createUser();
Severity: Major
Found in packages/oae-principals/lib/rest.user.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Confirmed

        return response.status(400).send('You need to accept the Terms and Conditions');
    Severity: Major
    Found in packages/oae-principals/lib/rest.user.js - About 30 mins to fix

      Similar blocks of code found in 7 locations. Consider refactoring.
      Open

      OAE.tenantRouter.on('get', '/api/user/:userId/memberships', (request, response) => {
        const limit = OaeUtil.getNumberParam(request.query.limit, 10, 1, 25);
        PrincipalsAPI.getMembershipsLibrary(
          request.ctx,
          request.params.userId,
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 6 other locations - About 6 hrs to fix
      packages/oae-folders/lib/rest.js on lines 289..304
      packages/oae-folders/lib/rest.js on lines 375..390
      packages/oae-folders/lib/rest.js on lines 492..507
      packages/oae-folders/lib/rest.js on lines 527..542
      packages/oae-following/lib/rest.js on lines 36..51
      packages/oae-following/lib/rest.js on lines 69..84

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

      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

      OAE.tenantRouter.on('post', '/api/user/:userId/email/verify', (request, response) => {
        PrincipalsAPI.verifyEmail(request.ctx, request.params.userId, request.body.token, (error, user) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 2 other locations - About 4 hrs to fix
      packages/oae-lti/lib/rest.js on lines 34..42
      packages/oae-tenants/lib/rest.js on lines 89..102

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

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

      OAE.tenantRouter.on('post', '/api/user/:userId/termsAndConditions', (request, response) => {
        PrincipalsAPI.acceptTermsAndConditions(request.ctx, request.params.userId, (error, user) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 3 other locations - About 3 hrs to fix
      packages/oae-authentication/lib/strategies/signed/rest.js on lines 45..57
      packages/oae-folders/lib/rest.js on lines 114..122
      packages/oae-tenants/lib/rest.js on lines 63..71

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

      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

      const _handleDeleteUser = function (request, response) {
        PrincipalsAPI.deleteUser(request.ctx, request.params.userId, (error) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 3 hrs to fix
      packages/oae-principals/lib/rest.user.js on lines 422..430

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

      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

      const _handleGetFullProfile = function (request, response) {
        PrincipalsAPI.getFullUserProfile(request.ctx, request.params.userId, (error, user) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 3 hrs to fix
      packages/oae-principals/lib/rest.user.js on lines 861..869

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

      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

      const _getUsersForTenant = function (request, response) {
        PrincipalsAPI.getAllUsersForTenant(request.ctx, request.params.tenantAlias, (error, users) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 3 hrs to fix
      packages/oae-principals/lib/rest.user.js on lines 616..624

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

      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

      const _handleRestoreUser = function (request, response) {
        PrincipalsAPI.restoreUser(request.ctx, request.params.userId, (error) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 3 hrs to fix
      packages/oae-principals/lib/rest.user.js on lines 390..398

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

      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

      const _handleResendEmailToken = function (request, response) {
        PrincipalsAPI.resendEmailToken(request.ctx, request.params.userId, (error) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 3 hrs to fix
      packages/oae-principals/lib/rest.user.js on lines 790..798

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

      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

      const _deleteEmailToken = function (request, response) {
        PrincipalsAPI.deleteEmailToken(request.ctx, request.params.userId, (error) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 3 hrs to fix
      packages/oae-principals/lib/rest.user.js on lines 733..741

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

      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

      const _handleUpdateUser = function (request, response) {
        PrincipalsAPI.updateUser(request.ctx, request.params.userId, request.body, (error, user) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 2 hrs to fix
      packages/oae-folders/lib/rest.js on lines 144..152

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

      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

      const _handleGetMe = function (request, response) {
        PrincipalsAPI.getMe(request.ctx, (error, meData) => {
          if (error) {
            return response.status(error.code).send(error.msg);
          }
      Severity: Major
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 2 hrs to fix
      packages/oae-ui/lib/rest.js on lines 108..116

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

      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

        const recaptchaData = {
          remoteip: request.connection.remoteAddress,
          challenge: request.body.recaptchaChallenge,
          response: request.body.recaptchaResponse
        };
      Severity: Minor
      Found in packages/oae-principals/lib/rest.user.js and 1 other location - About 35 mins to fix
      packages/oae-content/lib/rest.js on lines 641..645

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

      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