enricostara/telegram-mt-node

View on GitHub

Showing 31 of 37 total issues

Function findPQ has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

PQFinder.prototype.findPQ = function () {
    if (!this._pq) {
        var num = this._pqNumber;
        var prime;
        for (var i = 0; i < 3; i++) {
Severity: Minor
Found in lib/security/pq-finder.js - About 6 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 setClientDHParams has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function setClientDHParams(callback, context) {
    mtproto.service.set_client_DH_params({
        props: {
            nonce: context.resPQ.nonce,
            server_nonce: context.resPQ.server_nonce,
Severity: Minor
Found in lib/auth/set-client-dh-params.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 parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

MessageParser.prototype.parse = function (message, duration) {
    if(!message || !message.getTypeName) {
        logger.error('Message undefined or unknown', message);
        return;
    }
Severity: Minor
Found in lib/message/message-parser.js - About 1 hr 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 requestDHParams has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function requestDHParams(callback, context) {
    var resPQ = context.resPQ;
    mtproto.service.req_DH_params({
        props: {
            nonce: resPQ.nonce,
Severity: Minor
Found in lib/auth/request-dh-params.js - About 1 hr 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 callMethod has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

EncryptedRpcChannel.prototype.callMethod = function (method, callback) {
    if (!this._open) {
        callback(new Error('Channel is closed'));
        return;
    }
Severity: Minor
Found in lib/net/encrypted-rpc-channel.js - About 1 hr to fix

    Function findPQ has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    PQFinder.prototype.findPQ = function () {
        if (!this._pq) {
            var num = this._pqNumber;
            var prime;
            for (var i = 0; i < 3; i++) {
    Severity: Minor
    Found in lib/security/pq-finder.js - About 1 hr to fix

      Function read has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      TcpConnection.prototype.read = function (callback) {
          var self = this;
          var buffers = [];
          var timer;
          if (logger.isDebugEnabled()) {
      Severity: Minor
      Found in lib/net/tcp-connection.js - About 1 hr to fix

        Function _executeCall has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        RpcChannel.prototype._executeCall = function (reqMsg, callback) {
            var conn = this._connection;
            var start = new Date().getTime();
            var self = this;
            conn.write(reqMsg.serialize(), function (ex) {
        Severity: Minor
        Found in lib/net/rpc-channel.js - About 1 hr to fix

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

          TcpConnection.prototype.connect = function (callback) {
              var self = this;
              if (logger.isDebugEnabled()) {
                  logger.debug('Connecting to %s', self._config);
              }
          Severity: Minor
          Found in lib/net/tcp-connection.js - About 1 hr to fix

            Function close has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            TcpConnection.prototype.close = function (callback) {
                var self = this;
                var socket = this._socket;
                if (socket) {
                    if (logger.isDebugEnabled()) {
            Severity: Minor
            Found in lib/net/tcp-connection.js - About 1 hr 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 EncryptedMessage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function EncryptedMessage(options) {
                var opts = options ? options : {};
                this.constructor.super_.call(this, opts.buffer, opts.offset);
                this.authKey = opts.authKey;
                if (opts.message) {
            Severity: Minor
            Found in lib/message/encrypted-message.js - About 1 hr 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 callMethod has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            EncryptedRpcChannel.prototype.callMethod = function (method, callback) {
                if (!this._open) {
                    callback(new Error('Channel is closed'));
                    return;
                }
            Severity: Minor
            Found in lib/net/encrypted-rpc-channel.js - About 1 hr 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 setClientDHParams has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function setClientDHParams(callback, context) {
                mtproto.service.set_client_DH_params({
                    props: {
                        nonce: context.resPQ.nonce,
                        server_nonce: context.resPQ.server_nonce,
            Severity: Minor
            Found in lib/auth/set-client-dh-params.js - About 1 hr to fix

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

              TcpConnection.prototype.write = function (data, callback) {
                  var self = this;
                  var socket = this._socket;
                  if (!socket && callback) {
                      callback(createError('Not yet connected', 'ENOTCONNECTED'));
              Severity: Minor
              Found in lib/net/tcp-connection.js - About 1 hr to fix

                Function requestDHParams has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function requestDHParams(callback, context) {
                    var resPQ = context.resPQ;
                    mtproto.service.req_DH_params({
                        props: {
                            nonce: resPQ.nonce,
                Severity: Minor
                Found in lib/auth/request-dh-params.js - About 1 hr to fix

                  Function _createRequest has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  HttpConnection.prototype._createRequest = function (options, callback) {
                      var request = http.request(options, function (res) {
                              if (logger.isDebugEnabled()) {
                                  logger.debug('reading from %s\nstatus: %s\nheaders: %s',
                                      this._config, res.statusCode, JSON.stringify(res.headers));
                  Severity: Minor
                  Found in lib/net/http-connection.js - About 1 hr to fix

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

                    MessageParser.prototype.parse = function (message, duration) {
                        if(!message || !message.getTypeName) {
                            logger.error('Message undefined or unknown', message);
                            return;
                        }
                    Severity: Minor
                    Found in lib/message/message-parser.js - About 1 hr to fix

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

                      EncryptedRpcChannel.prototype._call = function (reqMsg, directCallback) {
                          var self = this;
                          var callback = directCallback || this._callbackMap[reqMsg.messageId];
                          try {
                              this.constructor.super_.prototype._call.call(this, reqMsg, function (ex, result, duration) {
                      Severity: Minor
                      Found in lib/net/encrypted-rpc-channel.js - About 1 hr to fix

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

                                callback: function (ex, setClientDHParamsAnswer) {
                                    if (ex) {
                                        logger.error(ex);
                                        if (callback) {
                                            callback(ex);
                        Severity: Minor
                        Found in lib/auth/set-client-dh-params.js - About 1 hr to fix

                          Function close has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          TcpConnection.prototype.close = function (callback) {
                              var self = this;
                              var socket = this._socket;
                              if (socket) {
                                  if (logger.isDebugEnabled()) {
                          Severity: Minor
                          Found in lib/net/tcp-connection.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language