oaeproject/Hilary

View on GitHub
packages/oae-principals/lib/api.group.js

Summary

Maintainability
C
1 day
Test Coverage
B
81%

Function createRequestJoinGroup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Wontfix

const createRequestJoinGroup = function (ctx, groupId, callback) {
  _validateJoinGroupRequest(ctx, groupId, (error) => {
    if (error) return callback(error);

    // If the request exists, return
Severity: Minor
Found in packages/oae-principals/lib/api.group.js - About 1 hr 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 createGroup has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

const createGroup = function (ctx, displayName, description, visibility, joinable, roles, callback) {
Severity: Major
Found in packages/oae-principals/lib/api.group.js - About 50 mins to fix

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

    const _getMembershipsLibrary = function (ctx, principalId, visibility, start, limit, callback, _items) {
    Severity: Major
    Found in packages/oae-principals/lib/api.group.js - About 50 mins to fix

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

      const _getMembersLibrary = function (ctx, group, hasRole, start, limit, callback) {
      Severity: Minor
      Found in packages/oae-principals/lib/api.group.js - About 45 mins to fix

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

        const getMembersLibrary = function (ctx, groupId, start, limit, callback) {
        Severity: Minor
        Found in packages/oae-principals/lib/api.group.js - About 35 mins to fix

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

          const getMembershipsLibrary = function (ctx, principalId, start, limit, callback) {
          Severity: Minor
          Found in packages/oae-principals/lib/api.group.js - About 35 mins to fix

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

            const resendGroupInvitation = function (ctx, groupId, email, callback) {
              try {
                unless(isGroupId, {
                  code: 400,
                  msg: 'A valid group id must be specified'
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 3 hrs to fix
            packages/oae-folders/lib/api.js on lines 923..940

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

            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

            const getGroupInvitations = function (ctx, groupId, callback) {
              try {
                unless(isGroupId, {
                  code: 400,
                  msg: 'A valid group id must be specified'
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 3 hrs to fix
            packages/oae-folders/lib/api.js on lines 895..912

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

            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

              ResourceActions.create(ctx, roles, createFn, (error, group, memberChangeInfo) => {
                if (error) {
                  return callback(error);
                }
            
            
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 2 other locations - About 3 hrs to fix
            packages/oae-discussions/lib/api.discussions.js on lines 142..154
            packages/oae-folders/lib/api.js on lines 169..181

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

            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

                  AuthzAPI.updateRoles(group.id, memberChangeInfo.changes, (error_) => {
                    if (error_) {
                      return callback(error_);
                    }
            
            
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 2 hrs to fix
            packages/oae-discussions/lib/api.discussions.js on lines 314..332

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

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

              try {
                unless(isGroupId, {
                  code: 400,
                  msg: 'Invalid groupId specified'
                })(groupId);
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 14 other locations - About 1 hr to fix
            packages/oae-authentication/lib/strategies/oauth/api.js on lines 39..51
            packages/oae-authentication/lib/strategies/oauth/api.js on lines 179..191
            packages/oae-jitsi/lib/api.meetings.js on lines 605..617
            packages/oae-resource/lib/actions.js on lines 410..422
            packages/oae-content/lib/api.js on lines 2389..2401
            packages/oae-content/lib/api.js on lines 2464..2476
            packages/oae-content/lib/api.js on lines 2733..2745
            packages/oae-discussions/lib/api.discussions.js on lines 1036..1047
            packages/oae-folders/lib/api.js on lines 954..966
            packages/oae-folders/lib/api.js on lines 1731..1743
            packages/oae-following/lib/api.js on lines 187..199
            packages/oae-following/lib/api.js on lines 246..258
            packages/oae-principals/lib/api.group.js on lines 646..658
            packages/oae-principals/lib/api.user.js on lines 1327..1339

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

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

              try {
                unless(isGroupId, {
                  code: 400,
                  msg: 'Invalid groupId specified'
                })(groupId);
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 14 other locations - About 1 hr to fix
            packages/oae-authentication/lib/strategies/oauth/api.js on lines 39..51
            packages/oae-authentication/lib/strategies/oauth/api.js on lines 179..191
            packages/oae-jitsi/lib/api.meetings.js on lines 605..617
            packages/oae-resource/lib/actions.js on lines 410..422
            packages/oae-content/lib/api.js on lines 2389..2401
            packages/oae-content/lib/api.js on lines 2464..2476
            packages/oae-content/lib/api.js on lines 2733..2745
            packages/oae-discussions/lib/api.discussions.js on lines 1036..1047
            packages/oae-folders/lib/api.js on lines 954..966
            packages/oae-folders/lib/api.js on lines 1731..1743
            packages/oae-following/lib/api.js on lines 187..199
            packages/oae-following/lib/api.js on lines 246..258
            packages/oae-principals/lib/api.group.js on lines 702..714
            packages/oae-principals/lib/api.user.js on lines 1327..1339

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

            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

                  unless(bothCheck(isField(JOINABLE), isIn), {
                    code: 400,
                    msg: 'The joinable setting must be one of: ' + _.values(AuthzConstants.joinable)
                  })(profileFields.joinable, _.values(AuthzConstants.joinable));
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 1 hr to fix
            packages/oae-principals/lib/api.group.js on lines 893..896

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

            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

                  unless(bothCheck(isField(VISIBILITY), isIn), {
                    code: 400,
                    msg: 'The visibility setting must be one of: ' + _.values(AuthzConstants.visibility)
                  })(profileFields.visibility, _.values(AuthzConstants.visibility));
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 1 hr to fix
            packages/oae-principals/lib/api.group.js on lines 897..900

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

            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

                  PrincipalsDAO.deletePrincipal(groupId, (error_) => {
                    if (error_) {
                      return callback(error_);
                    }
            
            
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 1 hr to fix
            packages/oae-principals/lib/api.group.js on lines 1040..1047

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

            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

                PrincipalsDAO.restorePrincipal(groupId, (error_) => {
                  if (error_) {
                    return callback(error_);
                  }
            
            
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 1 hr to fix
            packages/oae-principals/lib/api.group.js on lines 1000..1007

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

            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 {
              isShortString,
              isMediumString,
              validateInCase: bothCheck,
              isRoleValid,
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 3 other locations - About 1 hr to fix
            packages/oae-resource/lib/actions.js on lines 37..48
            packages/oae-authentication/lib/api.js on lines 63..74
            packages/oae-content/lib/model.js on lines 42..53

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

                unless(isIn, {
                  code: 400,
                  msg: 'The visibility setting must be one of: ' + _.values(AuthzConstants.visibility)
                })(visibility, _.values(AuthzConstants.visibility));
            Severity: Minor
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 50 mins to fix
            packages/oae-principals/lib/api.group.js on lines 810..813

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

                unless(isIn, {
                  code: 400,
                  msg: 'The joinable setting must be one of: ' + _.values(AuthzConstants.joinable)
                })(joinable, _.values(AuthzConstants.joinable));
            Severity: Minor
            Found in packages/oae-principals/lib/api.group.js and 1 other location - About 50 mins to fix
            packages/oae-principals/lib/api.group.js on lines 806..809

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

              try {
                unless(isGroupId, {
                  code: 400,
                  msg: 'An invalid group id was specified'
                })(groupId);
            Severity: Major
            Found in packages/oae-principals/lib/api.group.js and 13 other locations - About 35 mins to fix
            packages/oae-authz/lib/invitations/dao.js on lines 405..412
            packages/oae-jitsi/lib/api.meetings.js on lines 294..301
            packages/oae-jitsi/lib/api.meetings.js on lines 852..859
            packages/oae-principals/lib/internal/dao.js on lines 282..289
            packages/oae-discussions/lib/api.discussions.js on lines 355..362
            packages/oae-discussions/lib/api.discussions.js on lines 466..473
            packages/oae-folders/lib/api.js on lines 1306..1313
            packages/oae-folders/lib/api.js on lines 1489..1496
            packages/oae-following/lib/api.js on lines 56..63
            packages/oae-following/lib/api.js on lines 124..131
            packages/oae-principals/lib/api.user.js on lines 795..802
            packages/oae-principals/lib/api.user.js on lines 1049..1056
            packages/oae-util/lib/mq.js on lines 365..372

            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