RocketChat/Rocket.Chat

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

Summary

Maintainability
F
3 wks
Test Coverage

File Rooms.ts has 1675 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 4 days to fix

    RoomsRaw has 132 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 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Function modelIndexes has 57 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 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 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 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 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

                            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 266..301

                        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

                            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 303..338

                        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

                            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 1502..1513

                        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

                            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 1676..1691

                        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

                            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 1601..1611

                        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

                            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 1589..1599

                        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 7 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 6 other locations - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 662..672
                        apps/meteor/server/models/raw/Rooms.ts on lines 903..915
                        apps/meteor/server/models/raw/Rooms.ts on lines 1566..1576
                        apps/meteor/server/models/raw/Rooms.ts on lines 1664..1674
                        apps/meteor/server/models/raw/Rooms.ts on lines 1693..1703
                        apps/meteor/server/models/raw/Rooms.ts on lines 1732..1742

                        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 7 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 6 other locations - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 662..672
                        apps/meteor/server/models/raw/Rooms.ts on lines 903..915
                        apps/meteor/server/models/raw/Rooms.ts on lines 1009..1019
                        apps/meteor/server/models/raw/Rooms.ts on lines 1566..1576
                        apps/meteor/server/models/raw/Rooms.ts on lines 1693..1703
                        apps/meteor/server/models/raw/Rooms.ts on lines 1732..1742

                        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 7 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 6 other locations - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 662..672
                        apps/meteor/server/models/raw/Rooms.ts on lines 1009..1019
                        apps/meteor/server/models/raw/Rooms.ts on lines 1566..1576
                        apps/meteor/server/models/raw/Rooms.ts on lines 1664..1674
                        apps/meteor/server/models/raw/Rooms.ts on lines 1693..1703
                        apps/meteor/server/models/raw/Rooms.ts on lines 1732..1742

                        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 7 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 6 other locations - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 662..672
                        apps/meteor/server/models/raw/Rooms.ts on lines 903..915
                        apps/meteor/server/models/raw/Rooms.ts on lines 1009..1019
                        apps/meteor/server/models/raw/Rooms.ts on lines 1566..1576
                        apps/meteor/server/models/raw/Rooms.ts on lines 1664..1674
                        apps/meteor/server/models/raw/Rooms.ts on lines 1693..1703

                        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 7 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 6 other locations - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 903..915
                        apps/meteor/server/models/raw/Rooms.ts on lines 1009..1019
                        apps/meteor/server/models/raw/Rooms.ts on lines 1566..1576
                        apps/meteor/server/models/raw/Rooms.ts on lines 1664..1674
                        apps/meteor/server/models/raw/Rooms.ts on lines 1693..1703
                        apps/meteor/server/models/raw/Rooms.ts on lines 1732..1742

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

                            setLastMessageById(_id: IRoom['_id'], lastMessage: IRoom['lastMessage']): Promise<UpdateResult> {
                                const query: Filter<IRoom> = { _id };
                        
                                const update: UpdateFilter<IRoom> = {
                                    $set: {
                        Severity: Major
                        Found in apps/meteor/server/models/raw/Rooms.ts and 6 other locations - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 662..672
                        apps/meteor/server/models/raw/Rooms.ts on lines 903..915
                        apps/meteor/server/models/raw/Rooms.ts on lines 1009..1019
                        apps/meteor/server/models/raw/Rooms.ts on lines 1664..1674
                        apps/meteor/server/models/raw/Rooms.ts on lines 1693..1703
                        apps/meteor/server/models/raw/Rooms.ts on lines 1732..1742

                        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 7 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 6 other locations - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 662..672
                        apps/meteor/server/models/raw/Rooms.ts on lines 903..915
                        apps/meteor/server/models/raw/Rooms.ts on lines 1009..1019
                        apps/meteor/server/models/raw/Rooms.ts on lines 1566..1576
                        apps/meteor/server/models/raw/Rooms.ts on lines 1664..1674
                        apps/meteor/server/models/raw/Rooms.ts on lines 1732..1742

                        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 2 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 1 other location - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 1846..1856

                        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

                            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 1 other location - About 3 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 1858..1868

                        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

                            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 1490..1500

                        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

                            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 1478..1488

                        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 1175..1177

                        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 1294..1298

                        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

                            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 1143..1147

                        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 1158..1162

                        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 3 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 2 other locations - About 2 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 654..656
                        apps/meteor/server/models/raw/Rooms.ts on lines 674..676

                        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 3 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 2 other locations - About 2 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 658..660
                        apps/meteor/server/models/raw/Rooms.ts on lines 674..676

                        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 3 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 2 other locations - About 2 hrs to fix
                        apps/meteor/server/models/raw/Rooms.ts on lines 654..656
                        apps/meteor/server/models/raw/Rooms.ts on lines 658..660

                        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 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 996..1007

                        Duplicated Code

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

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

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

                        Tuning

                        This issue has a mass of 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

                            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 936..938

                        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 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 471..480

                        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 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 455..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 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 266..301
                        apps/meteor/server/models/raw/Rooms.ts on lines 303..338

                        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 678..685

                        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 632..639

                        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 112..125

                        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 841..845

                        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 862..866

                        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

                                        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 438..446

                        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

                                        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 429..437

                        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 53..57
                        apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 86..90
                        apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 91..95
                        apps/meteor/server/models/raw/Rooms.ts on lines 1241..1241

                        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 53..57
                        apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 86..90
                        apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.ts on lines 91..95
                        apps/meteor/server/models/raw/Rooms.ts on lines 1210..1210

                        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 136..140

                        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 235..244
                        apps/meteor/server/models/raw/Rooms.ts on lines 800..813
                        apps/meteor/server/models/raw/Rooms.ts on lines 1387..1394
                        apps/meteor/server/models/raw/Rooms.ts on lines 1409..1418

                        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 800..813
                        apps/meteor/server/models/raw/Rooms.ts on lines 1198..1207
                        apps/meteor/server/models/raw/Rooms.ts on lines 1387..1394
                        apps/meteor/server/models/raw/Rooms.ts on lines 1409..1418

                        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 235..244
                        apps/meteor/server/models/raw/Rooms.ts on lines 800..813
                        apps/meteor/server/models/raw/Rooms.ts on lines 1198..1207
                        apps/meteor/server/models/raw/Rooms.ts on lines 1409..1418

                        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 235..244
                        apps/meteor/server/models/raw/Rooms.ts on lines 800..813
                        apps/meteor/server/models/raw/Rooms.ts on lines 1198..1207
                        apps/meteor/server/models/raw/Rooms.ts on lines 1387..1394

                        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 235..244
                        apps/meteor/server/models/raw/Rooms.ts on lines 1198..1207
                        apps/meteor/server/models/raw/Rooms.ts on lines 1387..1394
                        apps/meteor/server/models/raw/Rooms.ts on lines 1409..1418

                        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 246..264
                        apps/meteor/server/models/raw/Rooms.ts on lines 574..581

                        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 550..563
                        apps/meteor/server/models/raw/Rooms.ts on lines 574..581

                        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 246..264
                        apps/meteor/server/models/raw/Rooms.ts on lines 550..563

                        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 1003..1011

                        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

                        Similar blocks of code found in 3 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: Minor
                        Found in apps/meteor/server/models/raw/Rooms.ts and 2 other locations - About 35 mins to fix
                        apps/meteor/server/models/raw/Subscriptions.ts on lines 930..937
                        apps/meteor/server/models/raw/Subscriptions.ts on lines 1013..1020

                        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 1387..1394

                        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 75..77
                        apps/meteor/ee/server/models/raw/LivechatRooms.ts on lines 79..81
                        apps/meteor/ee/server/models/raw/LivechatRooms.ts on lines 87..89

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

                            async findBySubscriptionUserIdUpdatedAfter(
                                userId: IUser['_id'],
                                _updatedAt: IRoom['_updatedAt'],
                                options: FindOptions<IRoom> = {},
                            ): Promise<FindCursor<IRoom>> {
                        Severity: Minor
                        Found in apps/meteor/server/models/raw/Rooms.ts and 2 other locations - About 30 mins to fix
                        apps/meteor/server/models/raw/Messages.ts on lines 122..133
                        apps/meteor/server/models/raw/Rooms.ts on lines 99..106

                        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