QuickBlox/quickblox-javascript-sdk

View on GitHub

Showing 4,299 of 4,299 total issues

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

    conn.xmlOutput = function(data) {
      if (data.childNodes[0]) {
        for (var i = 0, len = data.childNodes.length; i < len; i++) {
          Utils.QBLog('[QBChat]', 'SENT:', data.childNodes[i]);
        }
Severity: Major
Found in src/qbStrophe.js and 1 other location - About 2 hrs to fix
src/qbStrophe.js on lines 21..27

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

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

    this.service.ajax(ajaxParams, function(err, res) {
      if (err) {
        // Don't ask me why.
        // Thanks to backend developers for this
        var isFakeErrorEmptyAddressBook = self._isFakeErrorEmptyAddressBook(err);
Severity: Major
Found in src/modules/qbAddressBook.js and 1 other location - About 2 hrs to fix
src/modules/qbAddressBook.js on lines 201..215

Duplicated Code

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

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

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

Tuning

This issue has a mass of 88.

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

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

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

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

Refactorings

Further Reading

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

    this.service.ajax(ajaxParams, function(err, res) {
      if (err) {
        // Don't ask me why.
        // Thanks to backend developers for this
        var isFakeErrorEmptyAddressBook = self._isFakeErrorEmptyAddressBook(err);
Severity: Major
Found in src/modules/qbAddressBook.js and 1 other location - About 2 hrs to fix
src/modules/qbAddressBook.js on lines 151..165

Duplicated Code

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

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

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

Tuning

This issue has a mass of 88.

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

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

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

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

Refactorings

Further Reading

Function QBLog has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    QBLog: function(){
        if (this.loggers) {
            for (var i=0; i<this.loggers.length; ++i) {
                this.loggers[i](arguments);
            }
Severity: Major
Found in src/qbUtils.js - About 2 hrs to fix

    Function getNames has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        getNames: function (callback) {
            /**
             * Callback for QB.chat.privacylist.getNames().
             * @param {Object} error - The error object
             * @param {Object} response - The privacy list object (var names = response.names;)
    Severity: Major
    Found in src/modules/chat/qbChat.js - About 2 hrs to fix

      Function getList has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getList: function (name, callback) {
              /**
               * Callback for QB.chat.privacylist.getList().
               * @param {Object} error - The error object
               * @param {Object} response - The privacy list object
      Severity: Major
      Found in src/modules/chat/qbChat.js - About 2 hrs to fix

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

                        self.connection.sendIQ(setAsActiveIq, function (setAsActiveStanzaResult) {
                            callback(null);
                        }, function (setAsActiveStanzaError) {
                            if (setAsActiveStanzaError) {
                                var setAsActiveErrorObject = chatUtils.getErrorFromXMLNode(setAsActiveStanzaError);
        Severity: Major
        Found in src/modules/chat/qbChat.js and 1 other location - About 2 hrs to fix
        src/modules/chat/qbChat.js on lines 2163..2172

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

        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

                    self.connection.sendIQ(iq, function (stanzaResult) {
                        callback(null);
                    }, function (stanzaError) {
                        if (stanzaError) {
                            var errorObject = chatUtils.getErrorFromXMLNode(stanzaError);
        Severity: Major
        Found in src/modules/chat/qbChat.js and 1 other location - About 2 hrs to fix
        src/modules/chat/qbChat.js on lines 2530..2539

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

        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

        Function setAsDefault has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            setAsDefault: function (name, callback) {
                /**
                 * Callback for QB.chat.privacylist.setAsDefault().
                 * @param {Object} error - The error object
                 * @callback setAsDefaultPrivacylistCallback
        Severity: Minor
        Found in src/modules/chat/qbChat.js - About 2 hrs 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

        Function attachMediaStream has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        WebRTCSession.prototype.attachMediaStream = function (elementId, stream, options) {
            var elem = document.getElementById(elementId);
        
            if (elem) {
                if (elem instanceof HTMLMediaElement) {
        Severity: Minor
        Found in src/modules/webrtc/qbWebRTCSession.js - About 2 hrs 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

        Function join has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            join: function (dialogIdOrJid, callback) {
                /**
                 * Callback for QB.chat.muc.join().
                 * @param {Object} error - Returns error object or null
                 * @param {Object} responce - Returns responce
        Severity: Minor
        Found in src/modules/chat/qbChat.js - About 2 hrs 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

                if(typeof stanza.querySelector === 'function') {
                    el = stanza.querySelector(elName);
                } else if(typeof stanza.getChild === 'function'){
                    el = stanza.getChild(elName) || stanza.children.find(child => typeof child.getChild === 'function' && this.getElement(child, elName));
                } else {
        Severity: Major
        Found in src/modules/chat/qbChatHelpers.js and 1 other location - About 2 hrs to fix
        src/modules/chat/qbChatHelpers.js on lines 123..130

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

        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

                if(typeof stanza.querySelector === 'function') {
                    el = stanza.querySelector(elName);
                    txt = el ? el.textContent : null;
                } else if(typeof stanza.getChildText === 'function') {
                    txt = stanza.getChildText(elName) || stanza.children.find(child => typeof child.getChildText === 'function' && this.getElementText(child, elName));
        Severity: Major
        Found in src/modules/chat/qbChatHelpers.js and 1 other location - About 2 hrs to fix
        src/modules/chat/qbChatHelpers.js on lines 96..102

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

        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

        Function Connection has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        function Connection() {
          var protocol = chatPRTCL.active === 1 ? chatPRTCL.bosh : chatPRTCL.websocket;
          var conn = new Strophe.Connection(protocol);
        
          if (chatPRTCL.active === 1) {
        Severity: Minor
        Found in src/qbStrophe.js - About 2 hrs 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

        Function _addEnableHandlers has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        StreamManagement.prototype._addEnableHandlers = function () {
            var self = this;
        
            if (Utils.getEnv().browser) {
                self._c.XAddTrackedHandler(_incomingStanzaHandler.bind(self));
        Severity: Minor
        Found in src/plugins/streamManagement.js - About 2 hrs 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

        Function _getStats has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        function _getStats(peer, lastResults, successCallback, errorCallback) {
            var statistic = {
                'local': {
                    'audio': {},
                    'video': {},
        Severity: Minor
        Found in src/modules/webrtc/qbRTCPeerConnection.js - About 2 hrs 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

        Function join has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            join: function (dialogIdOrJid, callback) {
                /**
                 * Callback for QB.chat.muc.join().
                 * @param {Object} error - Returns error object or null
                 * @param {Object} responce - Returns responce
        Severity: Major
        Found in src/modules/chat/qbChat.js - About 2 hrs to fix

          File qbChatHelpers.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          'use strict';
          
          var utils = require('../../qbUtils');
          var config = require('../../qbConfig');
          
          
          Severity: Minor
          Found in src/modules/chat/qbChatHelpers.js - About 2 hrs to fix

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

                    if (Utils.getEnv().browser) {
                        if (config.streamManagement.enable) {
                            message.id = paramsCreateMsg.id;
                            message.jid_or_user_id = jid_or_user_id;
                            self.connection.send(stanza, message);
            Severity: Major
            Found in src/modules/chat/qbChat.js and 1 other location - About 2 hrs to fix
            src/modules/chat/qbChat.js on lines 1123..1132

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

            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

                    } else {
                        if (config.streamManagement.enable) {
                            message.id = paramsCreateMsg.id;
                            message.jid_or_user_id = jid_or_user_id;
                            self.Client.send(stanza, message);
            Severity: Major
            Found in src/modules/chat/qbChat.js and 1 other location - About 2 hrs to fix
            src/modules/chat/qbChat.js on lines 1115..1123

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

            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

            Severity
            Category
            Status
            Source
            Language