oaeproject/Hilary

View on GitHub
packages/oae-folders/lib/rest.js

Summary

Maintainability
F
1 wk
Test Coverage
A
99%

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

OAE.tenantRouter.on('get', '/api/folder/:folderId/members', (request, response) => {
  const limit = OaeUtil.getNumberParam(request.query.limit, 10, 1, 25);
  FoldersAPI.getFolderMembers(
    request.ctx,
    request.params.folderId,
Severity: Major
Found in packages/oae-folders/lib/rest.js and 6 other locations - About 6 hrs to fix
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
packages/oae-principals/lib/rest.user.js on lines 646..661

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

OAE.tenantRouter.on('get', '/api/folder/library/:principalId', (request, response) => {
  const limit = OaeUtil.getNumberParam(request.query.limit, 12, 1, 25);
  FoldersAPI.getFoldersLibrary(
    request.ctx,
    request.params.principalId,
Severity: Major
Found in packages/oae-folders/lib/rest.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 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
packages/oae-principals/lib/rest.user.js on lines 646..661

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

OAE.tenantRouter.on('get', '/api/folder/:folderId/library', (request, response) => {
  const limit = OaeUtil.getNumberParam(request.query.limit, 12, 1, 25);
  FoldersAPI.getFolderContentLibrary(
    request.ctx,
    request.params.folderId,
Severity: Major
Found in packages/oae-folders/lib/rest.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 527..542
packages/oae-following/lib/rest.js on lines 36..51
packages/oae-following/lib/rest.js on lines 69..84
packages/oae-principals/lib/rest.user.js on lines 646..661

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

OAE.tenantRouter.on('get', '/api/folder/:folderId/messages', (request, response) => {
  const limit = OaeUtil.getNumberParam(request.query.limit, 10, 1, 25);
  FoldersAPI.getMessages(
    request.ctx,
    request.params.folderId,
Severity: Major
Found in packages/oae-folders/lib/rest.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-following/lib/rest.js on lines 36..51
packages/oae-following/lib/rest.js on lines 69..84
packages/oae-principals/lib/rest.user.js on lines 646..661

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('delete', '/api/folder/:folderId/library', (request, response) => {
  const contentIds = OaeUtil.toArray(request.body.contentIds);
  FoldersAPI.removeContentItemsFromFolder(request.ctx, request.params.folderId, contentIds, (error) => {
    if (error) {
      return response.status(error.code).send(error.msg);
Severity: Major
Found in packages/oae-folders/lib/rest.js and 2 other locations - About 5 hrs to fix
packages/oae-folders/lib/rest.js on lines 230..239
packages/oae-folders/lib/rest.js on lines 436..445

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

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/folder/:folderId/library', (request, response) => {
  const contentIds = OaeUtil.toArray(request.body.contentIds);
  FoldersAPI.addContentItemsToFolder(request.ctx, request.params.folderId, contentIds, (error) => {
    if (error) {
      return response.status(error.code).send(error.msg);
Severity: Major
Found in packages/oae-folders/lib/rest.js and 2 other locations - About 5 hrs to fix
packages/oae-folders/lib/rest.js on lines 230..239
packages/oae-folders/lib/rest.js on lines 464..473

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

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/folder/:folderId/share', (request, response) => {
  const viewers = OaeUtil.toArray(request.body.viewers);
  FoldersAPI.shareFolder(request.ctx, request.params.folderId, viewers, (error) => {
    if (error) {
      return response.status(error.code).send(error.msg);
Severity: Major
Found in packages/oae-folders/lib/rest.js and 2 other locations - About 5 hrs to fix
packages/oae-folders/lib/rest.js on lines 436..445
packages/oae-folders/lib/rest.js on lines 464..473

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

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('delete', '/api/folder/library/:principalId/:folderId', (request, response) => {
  FoldersAPI.removeFolderFromLibrary(request.ctx, request.params.principalId, request.params.folderId, (error) => {
    if (error) {
      return response.status(error.code).send(error.msg);
    }
Severity: Major
Found in packages/oae-folders/lib/rest.js and 2 other locations - About 4 hrs to fix
packages/oae-content/lib/rest.js on lines 865..873
packages/oae-folders/lib/rest.js on lines 349..357

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

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/folder/:folderId/invitations/:email/resend', (request, response) => {
  FoldersAPI.resendFolderInvitation(request.ctx, request.params.folderId, request.params.email, (error) => {
    if (error) {
      return response.status(error.code).send(error.msg);
    }
Severity: Major
Found in packages/oae-folders/lib/rest.js and 2 other locations - About 4 hrs to fix
packages/oae-content/lib/rest.js on lines 865..873
packages/oae-folders/lib/rest.js on lines 408..416

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

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('get', '/api/folder/:folderId/invitations', (request, response) => {
  FoldersAPI.getFolderInvitations(request.ctx, request.params.folderId, (error, invitations) => {
    if (error) {
      return response.status(error.code).send(error.msg);
    }
Severity: Major
Found in packages/oae-folders/lib/rest.js and 3 other locations - About 4 hrs to fix
packages/oae-lti/lib/rest.js on lines 103..111
packages/oae-content/lib/rest.js on lines 837..845
packages/oae-ui/lib/rest.js on lines 133..141

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

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('get', '/api/folder/:folderId', (request, response) => {
  FoldersAPI.getFullFolderProfile(request.ctx, request.params.folderId, (error, folder) => {
    if (error) {
      return response.status(error.code).send(error.msg);
    }
Severity: Major
Found in packages/oae-folders/lib/rest.js and 3 other locations - About 3 hrs to fix
packages/oae-authentication/lib/strategies/signed/rest.js on lines 45..57
packages/oae-principals/lib/rest.user.js on lines 65..73
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

OAE.tenantRouter.on('post', '/api/folder/:folderId', (request, response) => {
  FoldersAPI.updateFolder(request.ctx, request.params.folderId, request.body, (error, updatedFolder) => {
    if (error) {
      return response.status(error.code).send(error.msg);
    }
Severity: Major
Found in packages/oae-folders/lib/rest.js and 1 other location - About 2 hrs to fix
packages/oae-principals/lib/rest.user.js on lines 588..596

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

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

  FoldersAPI.deleteFolder(request.ctx, request.params.folderId, deleteContent, (error, failedContent) => {
    if (error) {
      return response.status(error.code).send(error.msg);
    }

Severity: Major
Found in packages/oae-folders/lib/rest.js and 1 other location - About 1 hr to fix
packages/oae-folders/lib/rest.js on lines 175..182

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

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

    (error, failedContent) => {
      if (error) {
        return response.status(error.code).send(error.msg);
      }

Severity: Major
Found in packages/oae-folders/lib/rest.js and 1 other location - About 1 hr to fix
packages/oae-folders/lib/rest.js on lines 204..211

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

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