RocketChat/Rocket.Chat

View on GitHub
apps/meteor/server/services/team/service.ts

Summary

Maintainability
F
1 wk
Test Coverage

File service.ts has 915 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Room, Authorization, Message, ServiceClassInternal } from '@rocket.chat/core-services';
import type {
    IListRoomsFilter,
    ITeamAutocompleteResult,
    ITeamCreateParams,
Severity: Major
Found in apps/meteor/server/services/team/service.ts - About 2 days to fix

    TeamService has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class TeamService extends ServiceClassInternal implements ITeamService {
        protected name = 'team';
    
        async create(
            uid: string,
    Severity: Minor
    Found in apps/meteor/server/services/team/service.ts - About 5 hrs to fix

      Function removeMembers has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          async removeMembers(uid: string, teamId: string, members: Array<ITeamMemberParams>): Promise<boolean> {
              const team = await Team.findOneById<Pick<ITeam, 'roomId' | '_id'>>(teamId, {
                  projection: { _id: 1, roomId: 1 },
              });
              if (!team) {
      Severity: Minor
      Found in apps/meteor/server/services/team/service.ts - About 3 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 create has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async create(
              uid: string,
              { team, room = { name: team.name, extraData: {} }, members, owner, sidepanel }: ITeamCreateParams,
          ): Promise<ITeam> {
              if (!(await checkUsernameAvailability(team.name))) {
      Severity: Major
      Found in apps/meteor/server/services/team/service.ts - About 3 hrs to fix

        Function addRooms has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            async addRooms(uid: string, rooms: Array<string>, teamId: string): Promise<Array<IRoom>> {
                if (!teamId) {
                    throw new Error('missing-teamId');
                }
                if (!rooms) {
        Severity: Minor
        Found in apps/meteor/server/services/team/service.ts - About 2 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 listRoomsOfUser has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async listRoomsOfUser(
                uid: string,
                teamId: string,
                userId: string,
                allowPrivateTeam: boolean,
        Severity: Minor
        Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

          Function autocomplete has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              async autocomplete(uid: string, name: string): Promise<ITeamAutocompleteResult[]> {
                  const nameRegex = new RegExp(`^${escapeRegExp(name).trim()}`, 'i');
          
                  const subscriptions = await Subscriptions.find<Pick<ISubscription, 'rid'>>({ 'u._id': uid }, { projection: { rid: 1 } }).toArray();
                  const subscriptionIds = subscriptions.map(({ rid }) => rid);
          Severity: Minor
          Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

            Function removeMembers has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async removeMembers(uid: string, teamId: string, members: Array<ITeamMemberParams>): Promise<boolean> {
                    const team = await Team.findOneById<Pick<ITeam, 'roomId' | '_id'>>(teamId, {
                        projection: { _id: 1, roomId: 1 },
                    });
                    if (!team) {
            Severity: Minor
            Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

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

                  async updateRoom(uid: string, rid: string, isDefault: boolean, canUpdateAnyRoom = false): Promise<IRoom> {
                      if (!rid) {
                          throw new Error('missing-roomId');
                      }
                      if (!uid) {
              Severity: Minor
              Found in apps/meteor/server/services/team/service.ts - 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 updateRoom has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async updateRoom(uid: string, rid: string, isDefault: boolean, canUpdateAnyRoom = false): Promise<IRoom> {
                      if (!rid) {
                          throw new Error('missing-roomId');
                      }
                      if (!uid) {
              Severity: Minor
              Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

                Function addRooms has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async addRooms(uid: string, rooms: Array<string>, teamId: string): Promise<Array<IRoom>> {
                        if (!teamId) {
                            throw new Error('missing-teamId');
                        }
                        if (!rooms) {
                Severity: Minor
                Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

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

                      async listRoomsOfUser(
                          uid: string,
                          teamId: string,
                          userId: string,
                          allowPrivateTeam: boolean,
                  Severity: Minor
                  Found in apps/meteor/server/services/team/service.ts - 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 removeRoom has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async removeRoom(uid: string, rid: string, teamId: string, canRemoveAnyRoom = false): Promise<IRoom> {
                          if (!teamId) {
                              throw new Error('missing-teamId');
                          }
                          if (!rid) {
                  Severity: Minor
                  Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

                    Function members has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async members(
                            uid: string,
                            teamId: string,
                            canSeeAll: boolean,
                            { offset, count }: IPaginationOptions = { offset: 0, count: 50 },
                    Severity: Minor
                    Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

                      Function listRooms has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async listRooms(
                              uid: string,
                              teamId: string,
                              filter: IListRoomsFilter,
                              { offset: skip, count: limit }: IPaginationOptions = { offset: 0, count: 50 },
                      Severity: Minor
                      Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

                        Function list has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async list(
                                uid: string,
                                { offset, count }: IPaginationOptions = { offset: 0, count: 50 },
                                { sort, query }: IQueryOptions<ITeam> = { sort: {} },
                            ): Promise<IRecordsWithTotal<ITeamInfo>> {
                        Severity: Minor
                        Found in apps/meteor/server/services/team/service.ts - About 1 hr to fix

                          Function removeRoom has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              async removeRoom(uid: string, rid: string, teamId: string, canRemoveAnyRoom = false): Promise<IRoom> {
                                  if (!teamId) {
                                      throw new Error('missing-teamId');
                                  }
                                  if (!rid) {
                          Severity: Minor
                          Found in apps/meteor/server/services/team/service.ts - 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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              async create(
                                  uid: string,
                                  { team, room = { name: team.name, extraData: {} }, members, owner, sidepanel }: ITeamCreateParams,
                              ): Promise<ITeam> {
                                  if (!(await checkUsernameAvailability(team.name))) {
                          Severity: Minor
                          Found in apps/meteor/server/services/team/service.ts - 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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              async update(uid: string, teamId: string, updateData: ITeamUpdateData): Promise<void> {
                                  const team = await Team.findOneById<Pick<ITeam, '_id' | 'roomId'>>(teamId, {
                                      projection: { roomId: 1 },
                                  });
                                  if (!team) {
                          Severity: Minor
                          Found in apps/meteor/server/services/team/service.ts - About 35 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

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

                              async removeRolesFromMember(teamId: string, userId: string, roles: Array<string>): Promise<boolean> {
                                  const isMember = await TeamMember.findOneByUserIdAndTeamId(userId, teamId, {
                                      projection: { _id: 1 },
                                  });
                          
                          
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 3 hrs to fix
                          apps/meteor/server/services/team/service.ts on lines 930..941

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

                          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

                              async addRolesToMember(teamId: string, userId: string, roles: Array<string>): Promise<boolean> {
                                  const isMember = await TeamMember.findOneByUserIdAndTeamId(userId, teamId, {
                                      projection: { _id: 1 },
                                  });
                          
                          
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 3 hrs to fix
                          apps/meteor/server/services/team/service.ts on lines 943..954

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

                          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

                                  for await (const record of records) {
                                      const rooms = Rooms.findByTeamId(record._id);
                                      const users = TeamMember.findByTeamId(record._id);
                                      results.push({
                                          ...record,
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 2 hrs to fix
                          apps/meteor/server/services/team/service.ts on lines 253..261

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 94.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                                  for await (const record of records) {
                                      const rooms = Rooms.findByTeamId(record._id);
                                      const users = TeamMember.findByTeamId(record._id);
                                      results.push({
                                          ...record,
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 2 hrs to fix
                          apps/meteor/server/services/team/service.ts on lines 281..289

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 94.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                              async getInfoById(teamId: string): Promise<Omit<ITeam, 'usernames'> | null> {
                                  return Team.findOne<Omit<ITeam, 'usernames'>>(
                                      {
                                          _id: teamId,
                                      },
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 2 hrs to fix
                          apps/meteor/server/services/team/service.ts on lines 956..963

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 82.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                              async getInfoByName(teamName: string): Promise<Omit<ITeam, 'usernames'> | null> {
                                  return Team.findOne<Omit<ITeam, 'usernames'>>(
                                      {
                                          name: teamName,
                                      },
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 2 hrs to fix
                          apps/meteor/server/services/team/service.ts on lines 965..972

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 82.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                              ): Promise<{ team?: Pick<ITeam, 'name' | 'roomId' | 'type'>; parentRoom?: Pick<IRoom, 'name' | 'fname' | 't' | '_id'> }> {
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 1 hr to fix
                          packages/core-services/src/types/ITeamService.ts on lines 131..131

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

                                  const user = await Users.findOneById<Pick<IUser, '_id' | 'username' | 'name'>>(uid, { projection: { username: 1, name: 1 } });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 3 other locations - About 1 hr to fix
                          apps/meteor/app/livechat/server/hooks/offlineMessageToChannel.ts on lines 21..26
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/manageDepartmentUnit.ts on lines 11..13
                          apps/meteor/ee/server/lib/syncUserRoles.ts on lines 61..61

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

                                  const team = await Team.findOneById<Pick<ITeam, 'roomId' | '_id'>>(teamId, {
                                      projection: { _id: 1, roomId: 1 },
                                  });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 13 other locations - About 1 hr to fix
                          apps/meteor/app/2fa/server/functions/resetTOTP.ts on lines 12..14
                          apps/meteor/app/livechat/server/lib/Departments.ts on lines 14..16
                          apps/meteor/app/livechat/server/methods/searchAgent.ts on lines 33..35
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts on lines 15..17
                          apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts on lines 78..81
                          apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts on lines 155..160
                          apps/meteor/ee/app/livechat-enterprise/server/methods/resumeOnHold.ts on lines 22..24
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 217..219
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 227..229
                          apps/meteor/server/services/team/service.ts on lines 328..328
                          apps/meteor/server/services/team/service.ts on lines 401..401
                          apps/meteor/server/services/team/service.ts on lines 526..528
                          apps/meteor/app/api/server/v1/im.ts on lines 416..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 55.

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

                                  const team = await Team.findOneById<Pick<ITeam, '_id' | 'type'>>(teamId, {
                                      projection: { _id: 1, type: 1 },
                                  });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 13 other locations - About 1 hr to fix
                          apps/meteor/app/2fa/server/functions/resetTOTP.ts on lines 12..14
                          apps/meteor/app/livechat/server/lib/Departments.ts on lines 14..16
                          apps/meteor/app/livechat/server/methods/searchAgent.ts on lines 33..35
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts on lines 15..17
                          apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts on lines 78..81
                          apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts on lines 155..160
                          apps/meteor/ee/app/livechat-enterprise/server/methods/resumeOnHold.ts on lines 22..24
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 217..219
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 227..229
                          apps/meteor/server/services/team/service.ts on lines 328..328
                          apps/meteor/server/services/team/service.ts on lines 401..401
                          apps/meteor/server/services/team/service.ts on lines 769..771
                          apps/meteor/app/api/server/v1/im.ts on lines 416..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 55.

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

                                  const team = await Team.findOneById<Pick<ITeam, '_id' | 'roomId'>>(teamId, { projection: { _id: 1, roomId: 1 } });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 13 other locations - About 1 hr to fix
                          apps/meteor/app/2fa/server/functions/resetTOTP.ts on lines 12..14
                          apps/meteor/app/livechat/server/lib/Departments.ts on lines 14..16
                          apps/meteor/app/livechat/server/methods/searchAgent.ts on lines 33..35
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts on lines 15..17
                          apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts on lines 78..81
                          apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts on lines 155..160
                          apps/meteor/ee/app/livechat-enterprise/server/methods/resumeOnHold.ts on lines 22..24
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 217..219
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 227..229
                          apps/meteor/server/services/team/service.ts on lines 328..328
                          apps/meteor/server/services/team/service.ts on lines 526..528
                          apps/meteor/server/services/team/service.ts on lines 769..771
                          apps/meteor/app/api/server/v1/im.ts on lines 416..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 55.

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

                                  const team = await Team.findOneById<Pick<ITeam, '_id' | 'roomId'>>(teamId, { projection: { _id: 1, roomId: 1 } });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 13 other locations - About 1 hr to fix
                          apps/meteor/app/2fa/server/functions/resetTOTP.ts on lines 12..14
                          apps/meteor/app/livechat/server/lib/Departments.ts on lines 14..16
                          apps/meteor/app/livechat/server/methods/searchAgent.ts on lines 33..35
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/resumeOnHold.ts on lines 15..17
                          apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts on lines 78..81
                          apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts on lines 155..160
                          apps/meteor/ee/app/livechat-enterprise/server/methods/resumeOnHold.ts on lines 22..24
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 217..219
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 227..229
                          apps/meteor/server/services/team/service.ts on lines 401..401
                          apps/meteor/server/services/team/service.ts on lines 526..528
                          apps/meteor/server/services/team/service.ts on lines 769..771
                          apps/meteor/app/api/server/v1/im.ts on lines 416..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 55.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                                  const userTeams = await TeamMember.findByUserId<Pick<ITeamMember, 'teamId'>>(userId, {
                                      projection: { teamId: 1 },
                                  }).toArray();
                          Severity: Minor
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 50 mins to fix
                          apps/meteor/server/services/team/service.ts on lines 228..230

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 52.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                                  const userTeams = await TeamMember.findByUserId<Pick<ITeamMember, 'teamId'>>(uid, {
                                      projection: { teamId: 1 },
                                  }).toArray();
                          Severity: Minor
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 50 mins to fix
                          apps/meteor/server/services/team/service.ts on lines 215..217

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

                              async listByNames<P extends Document>(
                                  names: Array<string>,
                                  options?: undefined | FindOptions<ITeam> | FindOptions<P extends ITeam ? ITeam : P>,
                              ): Promise<P[] | ITeam[]> {
                                  if (options === undefined) {
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 2 other locations - About 50 mins to fix
                          apps/meteor/server/models/raw/Team.ts on lines 22..30
                          apps/meteor/server/models/raw/TeamMember.ts on lines 81..86

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 51.

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

                                  const team = await Team.findOneById<Pick<ITeam, '_id' | 'roomId'>>(teamId, {
                                      projection: { roomId: 1 },
                                  });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 9 other locations - About 45 mins to fix
                          apps/meteor/app/authorization/server/functions/getUsersInRole.ts on lines 35..35
                          apps/meteor/app/e2e/server/methods/setRoomKeyID.ts on lines 35..35
                          apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts on lines 111..111
                          apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts on lines 128..128
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.ts on lines 12..14
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.ts on lines 20..22
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/manageDepartmentUnit.ts on lines 29..31
                          apps/meteor/server/services/banner/service.ts on lines 92..94
                          apps/meteor/server/services/team/service.ts on lines 55..57

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

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

                                  const createdBy = await Users.findOneById<Pick<IUser, 'username' | '_id'>>(uid, {
                                      projection: { username: 1 },
                                  });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 9 other locations - About 45 mins to fix
                          apps/meteor/app/authorization/server/functions/getUsersInRole.ts on lines 35..35
                          apps/meteor/app/e2e/server/methods/setRoomKeyID.ts on lines 35..35
                          apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts on lines 111..111
                          apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts on lines 128..128
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.ts on lines 12..14
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.ts on lines 20..22
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/manageDepartmentUnit.ts on lines 29..31
                          apps/meteor/server/services/banner/service.ts on lines 92..94
                          apps/meteor/server/services/team/service.ts on lines 144..146

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

                          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

                                  const team = await Team.findOneById(room.teamId, { projection: { _id: 1, name: 1, roomId: 1, type: 1 } });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 2 other locations - About 40 mins to fix
                          apps/meteor/app/lib/server/functions/deleteMessage.ts on lines 38..38
                          apps/meteor/app/message-mark-as-unread/server/unreadMessages.ts on lines 55..62

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

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                                  const room = await Rooms.findOneById<Pick<IRoom, 'name'>>(team.roomId, { projection: { name: 1 } });
                          Severity: Minor
                          Found in apps/meteor/server/services/team/service.ts and 1 other location - About 40 mins to fix
                          apps/meteor/server/services/authorization/canAccessRoom.ts on lines 31..33

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 48.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                                  const team = await Team.findOneById<Pick<ITeam, 'roomId'>>(teamId, {
                                      projection: { roomId: 1 },
                                  });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 18 other locations - About 30 mins to fix
                          apps/meteor/app/api/server/lib/messages.ts on lines 25..25
                          apps/meteor/app/api/server/lib/messages.ts on lines 64..64
                          apps/meteor/app/authorization/server/methods/addUserToRole.ts on lines 35..35
                          apps/meteor/app/authorization/server/methods/removeUserFromRole.ts on lines 35..35
                          apps/meteor/app/lib/server/lib/notifyListener.ts on lines 167..169
                          apps/meteor/app/lib/server/lib/notifyListener.ts on lines 417..417
                          apps/meteor/app/livechat/server/lib/Contacts.ts on lines 231..231
                          apps/meteor/app/livechat/server/lib/Contacts.ts on lines 295..295
                          apps/meteor/app/statistics/server/lib/SAUMonitor.ts on lines 27..27
                          apps/meteor/ee/app/livechat-enterprise/server/api/lib/priorities.ts on lines 88..88
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeForwardRoomToDepartment.ts on lines 19..21
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadForwardDepartmentRestrictions.ts on lines 13..15
                          apps/meteor/ee/server/configuration/videoConference.ts on lines 23..23
                          apps/meteor/ee/server/configuration/videoConference.ts on lines 35..35
                          apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts on lines 65..65
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 343..343
                          apps/meteor/server/services/banner/service.ts on lines 51..53
                          apps/meteor/server/services/team/service.ts on lines 428..428

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

                                  const team = await Team.findOneById<Pick<ITeam, 'roomId'>>(teamId, { projection: { roomId: 1 } });
                          Severity: Major
                          Found in apps/meteor/server/services/team/service.ts and 18 other locations - About 30 mins to fix
                          apps/meteor/app/api/server/lib/messages.ts on lines 25..25
                          apps/meteor/app/api/server/lib/messages.ts on lines 64..64
                          apps/meteor/app/authorization/server/methods/addUserToRole.ts on lines 35..35
                          apps/meteor/app/authorization/server/methods/removeUserFromRole.ts on lines 35..35
                          apps/meteor/app/lib/server/lib/notifyListener.ts on lines 167..169
                          apps/meteor/app/lib/server/lib/notifyListener.ts on lines 417..417
                          apps/meteor/app/livechat/server/lib/Contacts.ts on lines 231..231
                          apps/meteor/app/livechat/server/lib/Contacts.ts on lines 295..295
                          apps/meteor/app/statistics/server/lib/SAUMonitor.ts on lines 27..27
                          apps/meteor/ee/app/livechat-enterprise/server/api/lib/priorities.ts on lines 88..88
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/beforeForwardRoomToDepartment.ts on lines 19..21
                          apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadForwardDepartmentRestrictions.ts on lines 13..15
                          apps/meteor/ee/server/configuration/videoConference.ts on lines 23..23
                          apps/meteor/ee/server/configuration/videoConference.ts on lines 35..35
                          apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts on lines 65..65
                          apps/meteor/server/modules/watchers/watchers.module.ts on lines 343..343
                          apps/meteor/server/services/banner/service.ts on lines 51..53
                          apps/meteor/server/services/team/service.ts on lines 714..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 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