RocketChat/Rocket.Chat

View on GitHub
apps/meteor/server/models/raw/Rooms.ts

Summary

Maintainability
F
3 wks
Test Coverage

File Rooms.ts has 1837 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type {
    IDirectMessageRoom,
    IMessage,
    IOmnichannelGenericRoom,
    IRoom,
Severity: Major
Found in apps/meteor/server/models/raw/Rooms.ts - About 5 days to fix

    RoomsRaw has 139 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class RoomsRaw extends BaseRaw<IRoom> implements IRoomsModel {
        constructor(db: Db, trash?: Collection<RocketChatRecordDeleted<IRoom>>) {
            super(db, 'room', trash);
        }
    
    
    Severity: Major
    Found in apps/meteor/server/models/raw/Rooms.ts - About 2 days to fix

      Function getChannelsWithNumberOfMessagesBetweenDateQuery has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getChannelsWithNumberOfMessagesBetweenDateQuery({
              types,
              start,
              end,
              startOfLastWeek,
      Severity: Major
      Found in apps/meteor/server/models/raw/Rooms.ts - About 4 hrs to fix

        Function findChildrenOfTeam has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            findChildrenOfTeam(
                teamId: string,
                teamRoomId: string,
                userId: string,
                filter?: string,
        Severity: Major
        Found in apps/meteor/server/models/raw/Rooms.ts - About 2 hrs to fix

          Function modelIndexes has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              modelIndexes(): IndexDescription[] {
                  return [
                      {
                          key: { name: 1 },
                          unique: true,
          Severity: Major
          Found in apps/meteor/server/models/raw/Rooms.ts - About 2 hrs to fix

            Function findByNameOrFNameAndTypesNotInIds has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                findByNameOrFNameAndTypesNotInIds(
                    name: IRoom['name'] | RegExp,
                    types: Array<IRoom['t']>,
                    ids: Array<IRoom['_id']>,
                    options: FindOptions<IRoom> = {},
            Severity: Minor
            Found in apps/meteor/server/models/raw/Rooms.ts - About 1 hr to fix

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

                  findPaginatedByNameOrFNameAndRoomIdsIncludingTeamRooms(
                      searchTerm: RegExp | null,
                      teamIds: Array<ITeam['_id']>,
                      roomIds: Array<IRoom['_id']>,
                      options: FindOptions<IRoom> = {},
              Severity: Minor
              Found in apps/meteor/server/models/raw/Rooms.ts - About 1 hr to fix

                Function findByNameOrFnameContainingAndTypes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    findByNameOrFnameContainingAndTypes(
                        name: NonNullable<IRoom['name']>,
                        types: Array<IRoom['t']>,
                        discussion = false,
                        teams = false,
                Severity: Minor
                Found in apps/meteor/server/models/raw/Rooms.ts - About 1 hr to fix

                  Function getSubscribedRoomIdsWithoutE2EKeys has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async getSubscribedRoomIdsWithoutE2EKeys(uid: IUser['_id']): Promise<IRoom['_id'][]> {
                          return (
                              await this.col
                                  .aggregate([
                                      { $match: { encrypted: true } },
                  Severity: Minor
                  Found in apps/meteor/server/models/raw/Rooms.ts - About 1 hr to fix

                    Function findPaginatedContainingNameOrFNameInIdsAsTeamMain has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        findPaginatedContainingNameOrFNameInIdsAsTeamMain(
                            searchTerm: RegExp | null,
                            rids: Array<IRoom['_id']>,
                            options: FindOptions<IRoom> = {},
                        ): FindPaginated<FindCursor<IRoom>> {
                    Severity: Minor
                    Found in apps/meteor/server/models/raw/Rooms.ts - About 1 hr to fix

                      Function findPaginatedRoomsWithoutDiscussionsByRoomIds has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          findPaginatedRoomsWithoutDiscussionsByRoomIds(
                              name: NonNullable<IRoom['name']>,
                              roomIds: Array<IRoom['_id']>,
                              options: FindOptions<IRoom> = {},
                          ): FindPaginated<FindCursor<IRoom>> {
                      Severity: Minor
                      Found in apps/meteor/server/models/raw/Rooms.ts - About 1 hr to fix

                        Function findRoomsWithoutDiscussionsByRoomIds has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            findRoomsWithoutDiscussionsByRoomIds(
                                name: NonNullable<IRoom['name']>,
                                roomIds: Array<IRoom['_id']>,
                                options: FindOptions<IRoom> = {},
                            ): FindCursor<IRoom> {
                        Severity: Minor
                        Found in apps/meteor/server/models/raw/Rooms.ts - About 1 hr to fix

                          Function findByNameAndTypeNotDefault has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              findByNameAndTypeNotDefault(
                                  name: IRoom['name'] | RegExp,
                                  type: IRoom['t'],
                                  options: FindOptions<IRoom> = {},
                                  includeFederatedRooms = false,
                          Severity: Minor
                          Found in apps/meteor/server/models/raw/Rooms.ts - About 1 hr to fix

                            Function findByNameOrFnameContainingAndTypes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                findByNameOrFnameContainingAndTypes(
                                    name: NonNullable<IRoom['name']>,
                                    types: Array<IRoom['t']>,
                                    discussion = false,
                                    teams = false,
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Rooms.ts - About 55 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

                                findRoomsWithoutDiscussionsByRoomIds(
                                    name: NonNullable<IRoom['name']>,
                                    roomIds: Array<IRoom['_id']>,
                                    options: FindOptions<IRoom> = {},
                                ): FindCursor<IRoom> {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 7 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 314..349

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

                            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

                                findPaginatedRoomsWithoutDiscussionsByRoomIds(
                                    name: NonNullable<IRoom['name']>,
                                    roomIds: Array<IRoom['_id']>,
                                    options: FindOptions<IRoom> = {},
                                ): FindPaginated<FindCursor<IRoom>> {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 7 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 277..312

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

                            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

                                setNameById(_id: IRoom['_id'], name: IRoom['name'], fname: IRoom['fname']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 4 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1668..1683

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

                            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

                                setAnnouncementById(
                                    _id: IRoom['_id'],
                                    announcement: IRoom['announcement'],
                                    announcementDetails: IRoom['announcementDetails'],
                                ): Promise<UpdateResult> {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 4 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1508..1519

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

                            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

                                replaceMutedUsername(previousUsername: IUser['username'], username: IUser['username']): Promise<Document | UpdateResult> {
                                    const query: Filter<IRoom> = { muted: previousUsername };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 4 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1581..1591

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 119.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                replaceUsername(previousUsername: IUser['username'], username: IUser['username']): Promise<Document | UpdateResult> {
                                    const query: Filter<IRoom> = { usernames: previousUsername };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 4 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1593..1603

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 119.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                setCallStatus(_id: IRoom['_id'], status: IRoom['callStatus']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = {
                                        _id,
                                    };
                            
                            
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 5 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 661..671
                            apps/meteor/server/models/raw/Rooms.ts on lines 1016..1026
                            apps/meteor/server/models/raw/Rooms.ts on lines 1656..1666
                            apps/meteor/server/models/raw/Rooms.ts on lines 1685..1695
                            apps/meteor/server/models/raw/Rooms.ts on lines 1724..1734

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

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

                                setFnameById(_id: IRoom['_id'], fname: IRoom['fname']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 5 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 910..922
                            apps/meteor/server/models/raw/Rooms.ts on lines 1016..1026
                            apps/meteor/server/models/raw/Rooms.ts on lines 1656..1666
                            apps/meteor/server/models/raw/Rooms.ts on lines 1685..1695
                            apps/meteor/server/models/raw/Rooms.ts on lines 1724..1734

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

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

                                setDescriptionById(_id: IRoom['_id'], description: IRoom['description']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = {
                                        _id,
                                    };
                                    const update: UpdateFilter<IRoom> = {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 5 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 661..671
                            apps/meteor/server/models/raw/Rooms.ts on lines 910..922
                            apps/meteor/server/models/raw/Rooms.ts on lines 1656..1666
                            apps/meteor/server/models/raw/Rooms.ts on lines 1685..1695
                            apps/meteor/server/models/raw/Rooms.ts on lines 1724..1734

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

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

                                setTopicById(_id: IRoom['_id'], topic: IRoom['topic']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 5 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 661..671
                            apps/meteor/server/models/raw/Rooms.ts on lines 910..922
                            apps/meteor/server/models/raw/Rooms.ts on lines 1016..1026
                            apps/meteor/server/models/raw/Rooms.ts on lines 1685..1695
                            apps/meteor/server/models/raw/Rooms.ts on lines 1724..1734

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

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

                                setCustomFieldsById(_id: IRoom['_id'], customFields: IRoom['customFields']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 5 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 661..671
                            apps/meteor/server/models/raw/Rooms.ts on lines 910..922
                            apps/meteor/server/models/raw/Rooms.ts on lines 1016..1026
                            apps/meteor/server/models/raw/Rooms.ts on lines 1656..1666
                            apps/meteor/server/models/raw/Rooms.ts on lines 1724..1734

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

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

                                unmuteMutedUsernameByRoomId(_id: IRoom['_id'], username: IUser['username']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $pull: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 5 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 661..671
                            apps/meteor/server/models/raw/Rooms.ts on lines 910..922
                            apps/meteor/server/models/raw/Rooms.ts on lines 1016..1026
                            apps/meteor/server/models/raw/Rooms.ts on lines 1656..1666
                            apps/meteor/server/models/raw/Rooms.ts on lines 1685..1695

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

                            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

                                saveRetentionFilesOnlyById(_id: IRoom['_id'], value: boolean): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1813..1823
                            apps/meteor/server/models/raw/Rooms.ts on lines 1825..1835
                            apps/meteor/server/models/raw/Rooms.ts on lines 1849..1859

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

                            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

                                saveRetentionExcludePinnedById(_id: IRoom['_id'], value: boolean): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1825..1835
                            apps/meteor/server/models/raw/Rooms.ts on lines 1837..1847
                            apps/meteor/server/models/raw/Rooms.ts on lines 1849..1859

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

                            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

                                saveRetentionOverrideGlobalById(_id: IRoom['_id'], value: boolean): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1813..1823
                            apps/meteor/server/models/raw/Rooms.ts on lines 1825..1835
                            apps/meteor/server/models/raw/Rooms.ts on lines 1837..1847

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

                            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

                                saveRetentionIgnoreThreadsById(_id: IRoom['_id'], value: boolean): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1813..1823
                            apps/meteor/server/models/raw/Rooms.ts on lines 1837..1847
                            apps/meteor/server/models/raw/Rooms.ts on lines 1849..1859

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

                            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

                                unarchiveById(_id: IRoom['_id']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1484..1494

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 101.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                archiveById(_id: IRoom['_id']): Promise<UpdateResult> {
                                    const query: Filter<IRoom> = { _id };
                            
                                    const update: UpdateFilter<IRoom> = {
                                        $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1496..1506

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 101.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                            includeFederatedRooms
                                                ? {
                                                        $or: [{ $and: [{ $or: [{ federated: { $exists: false } }, { federated: false }], name }] }, { federated: true, fname: name }],
                                                  }
                                                : { $or: [{ federated: { $exists: false } }, { federated: false }], name },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1173..1175

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 99.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                        ...(includeFederatedRooms
                                            ? { $or: [{ $and: [{ $or: [{ federated: { $exists: false } }, { federated: false }], name }] }, { federated: true, fname: name }] }
                                            : { $or: [{ federated: { $exists: false } }, { federated: false }], name }),
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 3 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1292..1296

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 99.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                getChannelsWithNumberOfMessagesBetweenDateQuery({
                                    types,
                                    start,
                                    end,
                                    startOfLastWeek,
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Analytics.ts on lines 219..315

                            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

                                findOneByDisplayName(fname: IRoom['fname'], options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
                                    const query: Filter<IRoom> = { fname };
                            
                                    return this.findOne(query, options);
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1141..1145

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

                            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

                                findOneByImportId(_id: IRoom['_id'], options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
                                    const query: Filter<IRoom> = { importIds: _id };
                            
                                    return this.findOne(query, options);
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1156..1160

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

                            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 presentationProject = {
                                        $project: {
                                            _id: 0,
                                            room: {
                                                _id: '$_id._id',
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Analytics.ts on lines 263..278

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

                            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

                                setRoomNameById(roomId: IRoom['_id'], name: IRoom['name']): Promise<UpdateResult> {
                                    return this.updateOne({ _id: roomId }, { $set: { name } });
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 2 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 649..651
                            apps/meteor/server/models/raw/Rooms.ts on lines 657..659
                            apps/meteor/server/models/raw/Rooms.ts on lines 673..675

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

                            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

                                setRoomTypeById(roomId: IRoom['_id'], roomType: IRoom['t']): Promise<UpdateResult> {
                                    return this.updateOne({ _id: roomId }, { $set: { t: roomType } });
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 2 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 653..655
                            apps/meteor/server/models/raw/Rooms.ts on lines 657..659
                            apps/meteor/server/models/raw/Rooms.ts on lines 673..675

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

                            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

                                setRoomTopicById(roomId: IRoom['_id'], topic: IRoom['description']): Promise<UpdateResult> {
                                    return this.updateOne({ _id: roomId }, { $set: { description: topic } });
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 2 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 649..651
                            apps/meteor/server/models/raw/Rooms.ts on lines 653..655
                            apps/meteor/server/models/raw/Rooms.ts on lines 657..659

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

                            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

                                setSidepanelById(roomId: IRoom['_id'], sidepanel: IRoom['sidepanel']): Promise<UpdateResult> {
                                    return this.updateOne({ _id: roomId }, { $set: { sidepanel } });
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 2 hrs to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 649..651
                            apps/meteor/server/models/raw/Rooms.ts on lines 653..655
                            apps/meteor/server/models/raw/Rooms.ts on lines 673..675

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

                            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

                                findChannelsByTypesWithNumberOfMessagesBetweenDate(params: {
                                    types: Array<IRoom['t']>;
                                    start: number;
                                    end: number;
                                    startOfLastWeek: number;
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Analytics.ts on lines 317..330

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

                            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

                                setLastMessageAsRead(roomId: IRoom['_id']): Promise<UpdateResult> {
                                    return this.updateOne(
                                        {
                                            _id: roomId,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 943..945

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

                            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

                                unsetReactionsInLastMessage(roomId: IRoom['_id']): Promise<UpdateResult> {
                                    return this.updateOne({ _id: roomId }, { $unset: { 'lastMessage.reactions': 1 } });
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1003..1014

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

                            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

                                setAsFederated(roomId: IRoom['_id']): Promise<UpdateResult> {
                                    return this.updateOne({ _id: roomId }, { $set: { federated: true } });
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/CalendarEvent.ts on lines 112..123

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

                            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 lastWeekMessagesGroup = {
                                        $group: {
                                            _id: {
                                                _id: '$room._id',
                                            },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 473..482

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 58.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                    const messagesGroup = {
                                        $group: {
                                            _id: {
                                                _id: '$room._id',
                                            },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 489..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 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 3 locations. Consider refactoring.
                            Open

                                findChannelAndGroupListWithoutTeamsByNameStartingByOwner(
                                    name: NonNullable<IRoom['name']>,
                                    groupsToAccept: Array<IRoom['_id']>,
                                    options: FindOptions<IRoom> = {},
                                ): FindCursor<IRoom> {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 2 other locations - About 1 hr to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 277..312
                            apps/meteor/server/models/raw/Rooms.ts on lines 314..349

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

                            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

                                findByBroadcast(options: FindOptions<IRoom> = {}): FindCursor<IRoom> {
                                    return this.find(
                                        {
                                            broadcast: true,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 2 other locations - About 1 hr to fix
                            apps/meteor/server/models/raw/Imports.ts on lines 47..49
                            apps/meteor/server/models/raw/Rooms.ts on lines 677..684

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

                            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

                                findByE2E(options: FindOptions<IRoom> = {}): FindCursor<IRoom> {
                                    return this.find(
                                        {
                                            encrypted: true,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 2 other locations - About 1 hr to fix
                            apps/meteor/server/models/raw/Imports.ts on lines 47..49
                            apps/meteor/server/models/raw/Rooms.ts on lines 636..643

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

                            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

                                findOneByIdOrName(_idOrName: IRoom['_id'] | IRoom['name'], options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
                                    const query: Filter<IRoom> = {
                                        $or: [
                                            {
                                                _id: _idOrName,
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Roles.ts on lines 114..127

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

                            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 findSmallestFederatedRoomInNumberOfUsers(options?: FindOptions<IRoom>): Promise<IRoom | undefined> {
                                    const asc = true;
                            
                                    return this.findFederatedRoomByAmountOfUsers(options, asc);
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 840..844

                            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

                                async findBiggestFederatedRoomInNumberOfUsers(options?: FindOptions<IRoom>): Promise<IRoom | undefined> {
                                    const asc = false;
                            
                                    return this.findFederatedRoomByAmountOfUsers(options, asc);
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 861..865

                            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

                                            lastWeekMessages: {
                                                $filter: {
                                                    input: '$messages',
                                                    as: 'message',
                                                    cond: {
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 447..455

                            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

                                            messages: {
                                                $filter: {
                                                    input: '$messages',
                                                    as: 'message',
                                                    cond: {
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 456..464

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

                                    const data = (await Subscriptions.findByUserId(userId, { projection: { rid: 1 } }).toArray()).map((item) => item.rid);
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 4 other locations - About 55 mins to fix
                            apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 56..60
                            apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 90..94
                            apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 95..99
                            apps/meteor/server/models/raw/Rooms.ts on lines 1239..1239

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

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

                                    const ids = (await Subscriptions.findByUserId(userId, { projection: { rid: 1 } }).toArray()).map((item) => item.rid);
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 4 other locations - About 55 mins to fix
                            apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 56..60
                            apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 90..94
                            apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 95..99
                            apps/meteor/server/models/raw/Rooms.ts on lines 1208..1208

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

                            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

                                findByTeamId(teamId: ITeam['_id'], options: FindOptions<IRoom> = {}): FindCursor<IRoom> {
                                    const query: Filter<IRoom> = {
                                        teamId,
                                        teamMain: {
                                            $exists: false,
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 50 mins to fix
                            apps/meteor/server/models/raw/Messages.ts on lines 135..139

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

                                findByTypeInIds(type: IRoom['t'], ids: Array<IRoom['_id']>, options: FindOptions<IRoom> = {}): FindCursor<IRoom> {
                                    const query: Filter<IRoom> = {
                                        _id: {
                                            $in: ids,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 4 other locations - About 50 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 246..255
                            apps/meteor/server/models/raw/Rooms.ts on lines 799..812
                            apps/meteor/server/models/raw/Rooms.ts on lines 1385..1392
                            apps/meteor/server/models/raw/Rooms.ts on lines 1407..1416

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

                                findByTypeAndName(type: IRoom['t'], name: NonNullable<IRoom['name']>, options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
                                    const query: Filter<IRoom> = {
                                        name,
                                        t: type,
                                    };
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 4 other locations - About 50 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 246..255
                            apps/meteor/server/models/raw/Rooms.ts on lines 799..812
                            apps/meteor/server/models/raw/Rooms.ts on lines 1196..1205
                            apps/meteor/server/models/raw/Rooms.ts on lines 1407..1416

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

                                findByTypeAndNameContaining(type: IRoom['t'], name: NonNullable<IRoom['name']>, options: FindOptions<IRoom> = {}): FindCursor<IRoom> {
                                    const nameRegex = new RegExp(escapeRegExp(name).trim(), 'i');
                            
                                    const query: Filter<IRoom> = {
                                        name: nameRegex,
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 4 other locations - About 50 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 246..255
                            apps/meteor/server/models/raw/Rooms.ts on lines 799..812
                            apps/meteor/server/models/raw/Rooms.ts on lines 1196..1205
                            apps/meteor/server/models/raw/Rooms.ts on lines 1385..1392

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

                                findPaginatedByTypeAndIds(
                                    type: IRoom['t'],
                                    ids: Array<IRoom['_id']>,
                                    options: FindOptions<IRoom> = {},
                                ): FindPaginated<FindCursor<IRoom>> {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 4 other locations - About 50 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 246..255
                            apps/meteor/server/models/raw/Rooms.ts on lines 1196..1205
                            apps/meteor/server/models/raw/Rooms.ts on lines 1385..1392
                            apps/meteor/server/models/raw/Rooms.ts on lines 1407..1416

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

                                findByTeamIdAndRoomsId(teamId: ITeam['_id'], rids: Array<IRoom['_id']>, options: FindOptions<IRoom> = {}): FindCursor<IRoom> {
                                    const query: Filter<IRoom> = {
                                        teamId,
                                        _id: {
                                            $in: rids,
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 4 other locations - About 50 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 799..812
                            apps/meteor/server/models/raw/Rooms.ts on lines 1196..1205
                            apps/meteor/server/models/raw/Rooms.ts on lines 1385..1392
                            apps/meteor/server/models/raw/Rooms.ts on lines 1407..1416

                            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

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

                                findOneByNameOrFname(name: NonNullable<IRoom['name'] | IRoom['fname']>, options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
                                    const query = {
                                        $or: [
                                            {
                                                name,
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 2 other locations - About 40 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 257..275
                            apps/meteor/server/models/raw/Rooms.ts on lines 578..585

                            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

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

                                async findOneByNonValidatedName(name: NonNullable<IRoom['name'] | IRoom['fname']>, options: FindOptions<IRoom> = {}) {
                                    const room = await this.findOneByNameOrFname(name, options);
                                    if (room) {
                                        return room;
                                    }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 2 other locations - About 40 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 257..275
                            apps/meteor/server/models/raw/Rooms.ts on lines 554..567

                            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

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

                                findRoomsByNameOrFnameStarting(name: NonNullable<IRoom['name'] | IRoom['fname']>, options: FindOptions<IRoom> = {}): FindCursor<IRoom> {
                                    const nameRegex = new RegExp(`^${escapeRegExp(name).trim()}`, 'i');
                            
                                    const query: Filter<IRoom> = {
                                        t: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 2 other locations - About 40 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 554..567
                            apps/meteor/server/models/raw/Rooms.ts on lines 578..585

                            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

                                findManyByRoomIds(roomIds: Array<IRoom['_id']>, options: FindOptions<IRoom> = {}): FindCursor<IRoom> {
                                    const query: Filter<IRoom> = {
                                        _id: {
                                            $in: roomIds,
                                        },
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 35 mins to fix
                            apps/meteor/server/models/raw/Subscriptions.ts on lines 1125..1133

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

                            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 sortAndPaginationParams: Exclude<Parameters<Collection<IRoom>['aggregate']>[0], undefined> = [sort];
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 35 mins to fix
                            apps/meteor/server/models/raw/Analytics.ts on lines 281..281

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 46.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                findOneByJoinCodeAndId(joinCode: string, rid: IRoom['_id'], options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
                                    const query: Filter<IRoom> = {
                                        _id: rid,
                                        joinCode,
                                    };
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Rooms.ts and 1 other location - About 35 mins to fix
                            apps/meteor/server/models/raw/Rooms.ts on lines 1385..1392

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 46.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                countDiscussions(): Promise<number> {
                                    return this.col.countDocuments({ prid: { $exists: true } });
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 30 mins to fix
                            apps/meteor/ee/server/models/raw/LivechatRooms.ts on lines 77..79
                            apps/meteor/ee/server/models/raw/LivechatRooms.ts on lines 81..83
                            apps/meteor/ee/server/models/raw/LivechatRooms.ts on lines 89..91

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

                                findOneByIdAndType(roomId: IRoom['_id'], type: IRoom['t'], options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
                                    return this.findOne({ _id: roomId, t: type }, options);
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 30 mins to fix
                            apps/meteor/server/models/raw/Messages.ts on lines 121..132
                            apps/meteor/server/models/raw/Rooms.ts on lines 110..117
                            apps/meteor/server/models/raw/Rooms.ts on lines 1234..1266

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

                                findOneByRoomIdAndUserId(rid: IRoom['_id'], uid: IUser['_id'], options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
                                    const query: Filter<IRoom> = {
                                        '_id': rid,
                                        'u._id': uid,
                                    };
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 30 mins to fix
                            apps/meteor/server/models/raw/Messages.ts on lines 121..132
                            apps/meteor/server/models/raw/Rooms.ts on lines 906..908
                            apps/meteor/server/models/raw/Rooms.ts on lines 1234..1266

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

                                async findBySubscriptionUserIdUpdatedAfter(
                                    userId: IUser['_id'],
                                    _updatedAt: IRoom['_updatedAt'],
                                    options: FindOptions<IRoom> = {},
                                ): Promise<FindCursor<IRoom>> {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Rooms.ts and 3 other locations - About 30 mins to fix
                            apps/meteor/server/models/raw/Messages.ts on lines 121..132
                            apps/meteor/server/models/raw/Rooms.ts on lines 110..117
                            apps/meteor/server/models/raw/Rooms.ts on lines 906..908

                            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