RocketChat/Rocket.Chat

View on GitHub
apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts

Summary

Maintainability
F
6 days
Test Coverage

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

    public async handle(externalEvent: MatrixEventRoomMessageSent): Promise<void> {
        const handlers = {
            [MatrixEnumSendMessageType.TEXT]: () => this.executeTextMessageHandler(externalEvent.content, externalEvent),
            [MatrixEnumSendMessageType.AUDIO]: () =>
                this.roomService.onExternalFileMessageReceived(MatrixRoomReceiverConverter.toSendRoomFileMessageDto(externalEvent)),

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

            const handlers = {
                [MatrixEnumSendMessageType.TEXT]: () => this.executeTextMessageHandler(externalEvent.content, externalEvent),
                [MatrixEnumSendMessageType.AUDIO]: () =>
                    this.roomService.onExternalFileMessageReceived(MatrixRoomReceiverConverter.toSendRoomFileMessageDto(externalEvent)),
                [MatrixEnumSendMessageType.FILE]: () =>
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 92..109

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

    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 threadHandlers = {
                [MatrixEnumSendMessageType.TEXT]: () => this.executeThreadedTextMessageHandler(externalEvent.content, externalEvent),
                [MatrixEnumSendMessageType.AUDIO]: () =>
                    this.roomService.onExternalThreadedFileMessageReceived(MatrixRoomReceiverConverter.toSendRoomFileMessageDto(externalEvent)),
                [MatrixEnumSendMessageType.FILE]: () =>
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 73..90

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

    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

        private executeTextMessageHandler(eventContent: IMatrixEventContentRoomMessageSent, externalEvent: MatrixEventRoomMessageSent): any {
            const isAnEditionEvent =
                eventContent['m.new_content'] &&
                eventContent['m.relates_to'] &&
                eventContent['m.relates_to'].rel_type === MatrixEnumRelatesToRelType.REPLACE;
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 59..70

    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

        private executeThreadedTextMessageHandler(
            eventContent: IMatrixEventContentRoomMessageSent,
            externalEvent: MatrixEventRoomMessageSent,
        ): any {
            const isAnEditionEvent =
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 49..57

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 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 8 locations. Consider refactoring.
    Open

    export class MatrixRoomJoinRulesChangedHandler extends MatrixBaseEventHandler {
        public eventType: string = MatrixEventType.ROOM_JOIN_RULES_CHANGED;
    
        constructor(private roomService: FederationRoomServiceReceiver) {
            super();
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Message.ts on lines 7..17
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 16..26
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 136..146
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 148..158
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 160..170
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 172..182
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/User.ts on lines 7..17

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

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

    export class MatrixRoomCreatedHandler extends MatrixBaseEventHandler {
        public eventType: string = MatrixEventType.ROOM_CREATED;
    
        constructor(private roomService: FederationRoomServiceReceiver) {
            super();
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Message.ts on lines 7..17
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 124..134
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 136..146
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 148..158
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 160..170
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 172..182
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/User.ts on lines 7..17

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

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

    export class MatrixRoomNameChangedHandler extends MatrixBaseEventHandler {
        public eventType: string = MatrixEventType.ROOM_NAME_CHANGED;
    
        constructor(private roomService: FederationRoomServiceReceiver) {
            super();
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Message.ts on lines 7..17
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 16..26
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 124..134
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 148..158
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 160..170
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 172..182
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/User.ts on lines 7..17

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

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

    export class MatrixRoomPowerLevelsChangedHandler extends MatrixBaseEventHandler {
        public eventType: string = MatrixEventType.ROOM_POWER_LEVELS_CHANGED;
    
        constructor(private roomService: FederationRoomServiceReceiver) {
            super();
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Message.ts on lines 7..17
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 16..26
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 124..134
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 136..146
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 148..158
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 160..170
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/User.ts on lines 7..17

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

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

    export class MatrixRoomTopicChangedHandler extends MatrixBaseEventHandler {
        public eventType: string = MatrixEventType.ROOM_TOPIC_CHANGED;
    
        constructor(private roomService: FederationRoomServiceReceiver) {
            super();
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Message.ts on lines 7..17
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 16..26
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 124..134
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 136..146
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 160..170
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 172..182
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/User.ts on lines 7..17

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

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

    export class MatrixRoomEventRedactedHandler extends MatrixBaseEventHandler {
        public eventType: string = MatrixEventType.ROOM_EVENT_REDACTED;
    
        constructor(private roomService: FederationRoomServiceReceiver) {
            super();
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Message.ts on lines 7..17
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 16..26
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 124..134
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 136..146
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 148..158
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/Room.ts on lines 172..182
    apps/meteor/server/services/federation/infrastructure/matrix/handlers/User.ts on lines 7..17

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

    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