HabitRPG/habitrpg

View on GitHub
website/server/controllers/api-v3/groups.js

Summary

Maintainability
F
1 wk
Test Coverage

File groups.js has 796 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from 'lodash';
import nconf from 'nconf';
import moment from 'moment';
import { authWithHeaders } from '../../middlewares/auth';
import {
Severity: Major
Found in website/server/controllers/api-v3/groups.js - About 1 day to fix

    Function handler has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
    Open

      async handler (req, res) {
        const { user } = res.locals;
        let inviter;
    
        req.checkParams('groupId', apiError('groupIdRequired')).notEmpty(); // .isUUID(); can't be used because it would block 'habitrpg' or 'party'
    Severity: Minor
    Found in website/server/controllers/api-v3/groups.js - About 1 day to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function handler has 155 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async handler (req, res) {
        const { user } = res.locals;
        let inviter;
    
        req.checkParams('groupId', apiError('groupIdRequired')).notEmpty(); // .isUUID(); can't be used because it would block 'habitrpg' or 'party'
    Severity: Major
    Found in website/server/controllers/api-v3/groups.js - About 6 hrs to fix

      Function handler has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

        async handler (req, res) {
          const { user } = res.locals;
      
          req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
          req.checkParams('memberId', res.t('userIdRequired')).notEmpty().isUUID();
      Severity: Minor
      Found in website/server/controllers/api-v3/groups.js - About 5 hrs 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 handler has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async handler (req, res) {
          const { user } = res.locals;
      
          req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
          req.checkParams('memberId', res.t('userIdRequired')).notEmpty().isUUID();
      Severity: Major
      Found in website/server/controllers/api-v3/groups.js - About 3 hrs to fix

        Function handler has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async handler (req, res) {
            const { user } = res.locals;
            const group = new Group(Group.sanitize(req.body.groupToCreate));
        
            req.checkBody('paymentType', res.t('paymentTypeRequired')).notEmpty();
        Severity: Major
        Found in website/server/controllers/api-v3/groups.js - About 2 hrs to fix

          Function handler has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async handler (req, res) {
              const USERS_PER_PAGE = 30;
              const { user } = res.locals;
          
              req.checkQuery('page').optional().isInt({ min: 0 }, apiError('queryPageInteger'));
          Severity: Major
          Found in website/server/controllers/api-v3/groups.js - About 2 hrs to fix

            Function handler has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async handler (req, res) {
                const { user } = res.locals;
            
                req.checkQuery('type', res.t('groupTypesRequired')).notEmpty();
                // pagination options, can only be used with public guilds
            Severity: Minor
            Found in website/server/controllers/api-v3/groups.js - About 2 hrs to fix

              Function handler has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                async handler (req, res) {
                  const { user } = res.locals;
              
                  req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
                  req.checkBody('summary', apiError('summaryLengthExceedsMax')).isLength({ max: MAX_SUMMARY_SIZE_FOR_GUILDS });
              Severity: Minor
              Found in website/server/controllers/api-v3/groups.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 handler has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async handler (req, res) {
                  const { user } = res.locals;
                  const group = new Group(Group.sanitize(req.body));
                  group.leader = user._id;
              
              
              Severity: Minor
              Found in website/server/controllers/api-v3/groups.js - About 1 hr to fix

                Function handler has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  async handler (req, res) {
                    const { user } = res.locals;
                
                    req.checkQuery('type', res.t('groupTypesRequired')).notEmpty();
                    // pagination options, can only be used with public guilds
                Severity: Minor
                Found in website/server/controllers/api-v3/groups.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 handler has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async handler (req, res) {
                    const { user } = res.locals;
                
                    req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
                    req.checkBody('summary', apiError('summaryLengthExceedsMax')).isLength({ max: MAX_SUMMARY_SIZE_FOR_GUILDS });
                Severity: Minor
                Found in website/server/controllers/api-v3/groups.js - About 1 hr to fix

                  Function handler has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async handler (req, res) {
                      const { user } = res.locals;
                  
                      if (user.flags.chatRevoked) throw new NotAuthorized(res.t('chatPrivilegesRevoked'));
                  
                  
                  Severity: Minor
                  Found in website/server/controllers/api-v3/groups.js - About 1 hr to fix

                    Function handler has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async handler (req, res) {
                        const USERS_PER_PAGE = 30;
                        const { user } = res.locals;
                    
                        req.checkQuery('page').optional().isInt({ min: 0 }, apiError('queryPageInteger'));
                    Severity: Minor
                    Found in website/server/controllers/api-v3/groups.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 handler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async handler (req, res) {
                        const { user } = res.locals;
                        req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
                        // When removing the user from challenges, should we keep the tasks?
                        req.checkQuery('keep', apiError('keepOrRemoveAll')).optional().isIn(['keep-all', 'remove-all']);
                    Severity: Minor
                    Found in website/server/controllers/api-v3/groups.js - About 1 hr to fix

                      Function handler has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        async handler (req, res) {
                          const { user } = res.locals;
                          const group = new Group(Group.sanitize(req.body));
                          group.leader = user._id;
                      
                      
                      Severity: Minor
                      Found in website/server/controllers/api-v3/groups.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 handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        async handler (req, res) {
                          const { user } = res.locals;
                      
                          req.checkParams('groupId', apiError('groupIdRequired')).notEmpty(); // .isUUID(); can't be used because it would block 'habitrpg' or 'party'
                      
                      
                      Severity: Minor
                      Found in website/server/controllers/api-v3/groups.js - About 45 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        async handler (req, res) {
                          const { user } = res.locals;
                          req.checkParams('groupId', apiError('groupIdRequired')).notEmpty();
                          // When removing the user from challenges, should we keep the tasks?
                          req.checkQuery('keep', apiError('keepOrRemoveAll')).optional().isIn(['keep-all', 'remove-all']);
                      Severity: Minor
                      Found in website/server/controllers/api-v3/groups.js - About 45 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Avoid deeply nested control flow statements.
                      Open

                                  if (userPreviousParty) await userPreviousParty.leave(user);
                      Severity: Major
                      Found in website/server/controllers/api-v3/groups.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if (userPreviousParty.memberCount === 1 && user.party.quest.key) {
                                      throw new NotAuthorized(res.t('messageCannotLeaveWhileQuesting'));
                                    }
                        Severity: Major
                        Found in website/server/controllers/api-v3/groups.js - About 45 mins to fix

                          Function handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            async handler (req, res) {
                              const { user } = res.locals;
                          
                              if (user.flags.chatRevoked) throw new NotAuthorized(res.t('chatPrivilegesRevoked'));
                          
                          
                          Severity: Minor
                          Found in website/server/controllers/api-v3/groups.js - About 45 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Function handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            async handler (req, res) {
                              const { user } = res.locals;
                              const group = new Group(Group.sanitize(req.body.groupToCreate));
                          
                              req.checkBody('paymentType', res.t('paymentTypeRequired')).notEmpty();
                          Severity: Minor
                          Found in website/server/controllers/api-v3/groups.js - About 45 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Avoid too many return statements within this function.
                          Open

                                return true;
                          Severity: Major
                          Found in website/server/controllers/api-v3/groups.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  if (user.inbox.blocks.indexOf(seeker._id) !== -1) return false;
                            Severity: Major
                            Found in website/server/controllers/api-v3/groups.js - About 30 mins to fix

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

                                    if (group.memberCount > 1) {
                                      const notification = new UserNotification({ type: 'ACHIEVEMENT_PARTY_UP' });
                              
                                      promises.push(User.updateMany(
                                        {
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 1 day to fix
                              website/server/controllers/api-v3/groups.js on lines 695..716

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

                              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 (group.memberCount > 3) {
                                      const notification = new UserNotification({ type: 'ACHIEVEMENT_PARTY_ON' });
                              
                                      promises.push(User.updateMany(
                                        {
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 1 day to fix
                              website/server/controllers/api-v3/groups.js on lines 672..693

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

                              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

                                member.notifications = member.notifications.filter(n => {
                                  if (n && n.type === 'NEW_CHAT_MESSAGE' && n.data && n.data.group && n.data.group.id === groupId) {
                                    return false;
                                  }
                              
                              
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 2 hrs to fix
                              website/server/controllers/api-v3/chat.js on lines 450..456

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

                              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

                                  res.analytics.track('join group', {
                                    uuid: user._id,
                                    hitType: 'event',
                                    category: 'behavior',
                                    owner: true,
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 1 hr to fix
                              website/server/controllers/api-v3/groups.js on lines 158..168

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

                              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

                                  const analyticsObject = {
                                    uuid: user._id,
                                    hitType: 'event',
                                    category: 'behavior',
                                    owner: true,
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 1 hr to fix
                              website/server/controllers/api-v3/groups.js on lines 208..218

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

                              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

                                    user.invitations.party = user.invitations.parties.length > 0
                                      ? user.invitations.parties[user.invitations.parties.length - 1]
                                      : {};
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 2 other locations - About 1 hr to fix
                              website/server/controllers/api-v3/groups.js on lines 1028..1030
                              website/server/models/group.js on lines 497..498

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

                              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

                                      member.invitations.party = member.invitations.parties.length > 0
                                        ? member.invitations.parties[member.invitations.parties.length - 1]
                                        : {};
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 2 other locations - About 1 hr to fix
                              website/server/controllers/api-v3/groups.js on lines 790..792
                              website/server/models/group.js on lines 497..498

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

                              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 (usernames) {
                                    const usernameInvites = usernames
                                      .map(username => inviteByUserName(username, group, user, req, res));
                                    const usernameResults = await Promise.all(usernameInvites);
                                    results.push(...usernameResults);
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 1 hr to fix
                              website/server/controllers/api-v3/groups.js on lines 1185..1189

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

                              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 (uuids) {
                                    const uuidInvites = uuids.map(uuid => inviteByUUID(uuid, group, user, req, res));
                                    const uuidResults = await Promise.all(uuidInvites);
                                    results.push(...uuidResults);
                                  }
                              Severity: Major
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 1 hr to fix
                              website/server/controllers/api-v3/groups.js on lines 1199..1204

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

                              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 (req.query.maxMemberCount) {
                                    if (!filters.memberCount) filters.memberCount = {};
                                    filters.memberCount.$lte = parseInt(req.query.maxMemberCount, 10);
                                  }
                              Severity: Minor
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 55 mins to fix
                              website/server/controllers/api-v3/groups.js on lines 333..336

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

                              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 (req.query.minMemberCount) {
                                    if (!filters.memberCount) filters.memberCount = {};
                                    filters.memberCount.$gte = parseInt(req.query.minMemberCount, 10);
                                  }
                              Severity: Minor
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 55 mins to fix
                              website/server/controllers/api-v3/groups.js on lines 338..341

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

                              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

                                  else if (group.leader !== user._id && !user.hasPermission('moderator')) throw new NotAuthorized(res.t('messageGroupOnlyLeaderCanUpdate'));
                              Severity: Minor
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 30 mins to fix
                              website/server/controllers/api-v3/groups.js on lines 968..968

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

                              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 (group.leader !== user._id && !user.hasPermission('moderator')) throw new NotAuthorized(res.t('onlyLeaderCanRemoveMember'));
                              Severity: Minor
                              Found in website/server/controllers/api-v3/groups.js and 1 other location - About 30 mins to fix
                              website/server/controllers/api-v3/groups.js on lines 488..488

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

                              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