Noosfero/noosfero

View on GitHub
public/javascripts/chat.js

Summary

Maintainability
F
4 days
Test Coverage

File chat.js has 856 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* XMPP/Jabber Noosfero's client

XMPP Core:
http://xmpp.org/rfcs/rfc3920.html

Severity: Major
Found in public/javascripts/chat.js - About 2 days to fix

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

        on_roster: function (iq) {
          log('receiving roster');
          var profiles = [];
          var contacts_to_insert = {};
          var groups_to_insert = [];
    Severity: Minor
    Found in public/javascripts/chat.js - About 1 hr to fix

      Function parse has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          parse: function (stanza) {
            var result = {};
            if (Strophe.isTagEqual(stanza, 'presence')) {
              result.from = $(stanza).attr('from');
              result.type = $(stanza).attr('type');
      Severity: Minor
      Found in public/javascripts/chat.js - About 1 hr to fix

        Function connect has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            connect: function() {
              if (("Notification" in window) && Notification.permission !== "granted" && Notification.permission !== "denied") {
                Notification.requestPermission(function (permission) {
                  if (!('permission' in Notification)) {
                    Notification.permission = permission;
        Severity: Minor
        Found in public/javascripts/chat.js - About 1 hr to fix

          Function on_connect has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              on_connect: function (status) {
                switch (status) {
                  case Strophe.Status.CONNECTING:
                    log('connecting...');
                  break;
          Severity: Minor
          Found in public/javascripts/chat.js - About 1 hr to fix

            Function create_conversation_tab has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function create_conversation_tab(title, jid_id) {
                var conversation_id = Jabber.conversation_prefix + jid_id;
                var conversation = $('#' + conversation_id);
                if (conversation.length > 0) {
                  return conversation;
            Severity: Minor
            Found in public/javascripts/chat.js - About 1 hr to fix

              Function success has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      success: function(data){
                        $(data.friends).each(function(index, friend){
                          var jid = friend.jid;
                          profiles.push(getIdentifier(jid));
                          var name = friend.name;
              Severity: Minor
              Found in public/javascripts/chat.js - About 1 hr to fix

                Function show_message has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    show_message: function (jid, name, body, who, identifier, time, offset) {
                      if(!offset) offset = 0;
                      if (body) {
                        body = Jabber.render_body_message(body);
                        var jid_id = Jabber.jid_to_id(jid);
                Severity: Minor
                Found in public/javascripts/chat.js - About 1 hr to fix

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

                      on_presence: function (presence) {
                        presence = Jabber.parse(presence);
                        if (presence.type != 'error') {
                          if (presence.is_from_room) {
                            log('receiving room presence from ' + presence.from + ' as ' + presence.show);
                  Severity: Minor
                  Found in public/javascripts/chat.js - About 1 hr to fix

                    Function insert_or_update_user has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        insert_or_update_user: function (list, item, jid, name, presence, template, type, remove_on_offline) {
                    Severity: Major
                    Found in public/javascripts/chat.js - About 1 hr to fix

                      Function show_message has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          show_message: function (jid, name, body, who, identifier, time, offset) {
                      Severity: Major
                      Found in public/javascripts/chat.js - About 50 mins to fix

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

                          jQuery.expr[':'].Contains = function(a,i,m){
                            return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
                          };
                        Severity: Major
                        Found in public/javascripts/chat.js and 1 other location - About 2 hrs to fix
                        plugins/display_content/public/javascripts/jstree-v.pre1.0/jquery.jstree.js on lines 3414..3416

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

                        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

                              presence = presence || ($(item).length > 0 ? $(item).parent('li').attr('class') : 'offline');
                        Severity: Minor
                        Found in public/javascripts/chat.js and 1 other location - About 40 mins to fix
                        public/javascripts/chat.js on lines 94..94

                        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

                              presence = presence || ($(item).length > 0 ? $(item).parent('li').attr('class') : 'offline');
                        Severity: Minor
                        Found in public/javascripts/chat.js and 1 other location - About 40 mins to fix
                        public/javascripts/chat.js on lines 84..84

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

                              $("#chat-window .tab a[href='#"+ Jabber.conversation_prefix + jid_id +"']")
                              .removeClass()
                              .addClass('icon-menu-' + presence + '-11');
                        Severity: Minor
                        Found in public/javascripts/chat.js and 1 other location - About 35 mins to fix
                        public/javascripts/chat.js 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 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

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

                              $("#chat-window .tab a[href='#"+ Jabber.conversation_prefix + jid_id +"']")
                              .removeClass()
                              .addClass('icon-menu-' + presence + '-11');
                        Severity: Minor
                        Found in public/javascripts/chat.js and 1 other location - About 35 mins to fix
                        public/javascripts/chat.js on lines 99..101

                        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

                        There are no issues that match your filters.

                        Category
                        Status