RocketChat/Rocket.Chat

View on GitHub
apps/meteor/app/apps/server/bridges/listeners.js

Summary

Maintainability
D
2 days
Test Coverage

Function messageEvent has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async messageEvent(inte, message, ...payload) {
        const msg = await this.orch.getConverters().get('messages').convertMessage(message);

        const params = (() => {
            switch (inte) {
Severity: Major
Found in apps/meteor/app/apps/server/bridges/listeners.js - About 2 hrs to fix

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

        async handleEvent(event, ...payload) {
            // eslint-disable-next-line complexity
            const method = (() => {
                switch (event) {
                    case AppInterface.IPreMessageSentPrevent:
    Severity: Minor
    Found in apps/meteor/app/apps/server/bridges/listeners.js - About 2 hrs to fix

      Function method has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              const method = (() => {
                  switch (event) {
                      case AppInterface.IPreMessageSentPrevent:
                      case AppInterface.IPreMessageSentExtend:
                      case AppInterface.IPreMessageSentModify:
      Severity: Minor
      Found in apps/meteor/app/apps/server/bridges/listeners.js - About 1 hr to fix

        Function params has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                const params = (() => {
                    switch (inte) {
                        case AppInterface.IPostMessageDeleted:
                            const [userDeleted] = payload;
                            return {
        Severity: Minor
        Found in apps/meteor/app/apps/server/bridges/listeners.js - About 1 hr to fix

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

              async livechatEvent(inte, data) {
                  switch (inte) {
                      case AppInterface.IPostLivechatAgentAssigned:
                      case AppInterface.IPostLivechatAgentUnassigned:
                          return this.orch
          Severity: Minor
          Found in apps/meteor/app/apps/server/bridges/listeners.js - About 1 hr to fix

            Function roomEvent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async roomEvent(inte, room, ...payload) {
                    const rm = await this.orch.getConverters().get('rooms').convertRoom(room);
            
                    const params = (() => {
                        switch (inte) {
            Severity: Minor
            Found in apps/meteor/app/apps/server/bridges/listeners.js - About 1 hr to fix

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

                  async userEvent(inte, data) {
                      let context;
                      switch (inte) {
                          case AppInterface.IPostUserLoggedIn:
                          case AppInterface.IPostUserLogout:
              Severity: Minor
              Found in apps/meteor/app/apps/server/bridges/listeners.js - About 1 hr to fix

                Avoid too many return statements within this function.
                Open

                                    return {
                                        message: msg,
                                        user: this.orch.getConverters().get('users').convertToApp(userReported),
                                        reason,
                                    };
                Severity: Major
                Found in apps/meteor/app/apps/server/bridges/listeners.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return {
                                          message: msg,
                                          user: this.orch.getConverters().get('users').convertToApp(userStarred),
                                          isStarred,
                                      };
                  Severity: Major
                  Found in apps/meteor/app/apps/server/bridges/listeners.js - About 30 mins to fix

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

                                case AppInterface.IPostLivechatRoomSaved:
                                    return this.orch
                                        .getManager()
                                        .getListenerManager()
                                        .executeListener(inte, await this.orch.getConverters().get('rooms').convertById(data));
                    Severity: Major
                    Found in apps/meteor/app/apps/server/bridges/listeners.js and 1 other location - About 1 hr to fix
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 187..191

                    Duplicated Code

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

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

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

                    Tuning

                    This issue has a mass of 67.

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

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

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

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

                    Refactorings

                    Further Reading

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

                                case AppInterface.IPostLivechatGuestSaved:
                                    return this.orch
                                        .getManager()
                                        .getListenerManager()
                                        .executeListener(inte, await this.orch.getConverters().get('visitors').convertById(data));
                    Severity: Major
                    Found in apps/meteor/app/apps/server/bridges/listeners.js and 1 other location - About 1 hr to fix
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 192..196

                    Duplicated Code

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

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

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

                    Tuning

                    This issue has a mass of 67.

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

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

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

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

                    Refactorings

                    Further Reading

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

                                    case AppInterface.IPostMessageStarred:
                                        const [userStarred, isStarred] = payload;
                                        return {
                                            message: msg,
                                            user: this.orch.getConverters().get('users').convertToApp(userStarred),
                    Severity: Major
                    Found in apps/meteor/app/apps/server/bridges/listeners.js and 3 other locations - About 1 hr to fix
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 90..96
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 97..103
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 111..117

                    Duplicated Code

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

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

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

                    Tuning

                    This issue has a mass of 64.

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

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

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

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

                    Refactorings

                    Further Reading

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

                                    case AppInterface.IPostMessageReported:
                                        const [userReported, reason] = payload;
                                        return {
                                            message: msg,
                                            user: this.orch.getConverters().get('users').convertToApp(userReported),
                    Severity: Major
                    Found in apps/meteor/app/apps/server/bridges/listeners.js and 3 other locations - About 1 hr to fix
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 90..96
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 97..103
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 104..110

                    Duplicated Code

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

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

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

                    Tuning

                    This issue has a mass of 64.

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

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

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

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

                    Refactorings

                    Further Reading

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

                                    case AppInterface.IPostMessagePinned:
                                        const [userPinned, isUnpinned] = payload;
                                        return {
                                            message: msg,
                                            user: this.orch.getConverters().get('users').convertToApp(userPinned),
                    Severity: Major
                    Found in apps/meteor/app/apps/server/bridges/listeners.js and 3 other locations - About 1 hr to fix
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 90..96
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 104..110
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 111..117

                    Duplicated Code

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

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

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

                    Tuning

                    This issue has a mass of 64.

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

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

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

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

                    Refactorings

                    Further Reading

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

                                    case AppInterface.IPostMessageFollowed:
                                        const [userFollowed, isUnfollow] = payload;
                                        return {
                                            message: msg,
                                            user: this.orch.getConverters().get('users').convertToApp(userFollowed),
                    Severity: Major
                    Found in apps/meteor/app/apps/server/bridges/listeners.js and 3 other locations - About 1 hr to fix
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 97..103
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 104..110
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 111..117

                    Duplicated Code

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

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

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

                    Tuning

                    This issue has a mass of 64.

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

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

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

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

                    Refactorings

                    Further Reading

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

                                    case AppInterface.IPostMessageDeleted:
                                        const [userDeleted] = payload;
                                        return {
                                            message: msg,
                                            user: this.orch.getConverters().get('users').convertToApp(userDeleted),
                    Severity: Major
                    Found in apps/meteor/app/apps/server/bridges/listeners.js and 1 other location - About 1 hr to fix
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 145..150

                    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

                                    case AppInterface.IPostRoomUserLeave:
                                        const [leavingUser] = payload;
                                        return {
                                            room: rm,
                                            leavingUser: this.orch.getConverters().get('users').convertToApp(leavingUser),
                    Severity: Major
                    Found in apps/meteor/app/apps/server/bridges/listeners.js and 1 other location - About 1 hr to fix
                    apps/meteor/app/apps/server/bridges/listeners.js on lines 76..81

                    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

                    There are no issues that match your filters.

                    Category
                    Status