enricostara/telegram-mt-node

View on GitHub

Showing 37 of 37 total issues

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

      Function write has a Cognitive Complexity of 10 (exceeds 5 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

      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 connect has a Cognitive Complexity of 10 (exceeds 5 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

      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 read has a Cognitive Complexity of 10 (exceeds 5 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

      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 deserialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      EncryptedMessage.prototype.deserialize = function (isSymmetric) {
          if (!this.isReadonly() || !this.authKey) {
              var msg = 'Unable to deserialize the message, "message" is not readonly || "authKey" is undefined!';
              logger.warn(msg);
              throw new Error(msg);
      Severity: Minor
      Found in lib/message/encrypted-message.js - About 1 hr to fix

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

        function decryptDHParams(context) {
            var newNonce = utility.string2Buffer(context.newNonce, 32);
            var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16);
            if (logger.isDebugEnabled()) {
                logger.debug('newNonce = %s, serverNonce = %s', newNonce.toString('hex'), serverNonce.toString('hex'));
        Severity: Minor
        Found in lib/auth/request-dh-params.js - About 1 hr to fix

          Function EncryptedMessage has 26 lines of code (exceeds 25 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

            Function createSHAHash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function createSHAHash(buffer, algorithm) {
                var logger = getLogger('utility.createSHA1Hash');
                var sha1sum = crypto.createHash(algorithm || 'sha1');
                if (require('util').isArray(buffer)) {
                    if (logger.isDebugEnabled()) {
            Severity: Minor
            Found in lib/utility.js - About 55 mins 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 findPublicKey has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function findPublicKey(context) {
                var fingerprints = context.resPQ.server_public_key_fingerprints.getList();
                if (logger.isDebugEnabled()) {
                    logger.debug('Public keys fingerprints from server: %s', fingerprints);
                }
            Severity: Minor
            Found in lib/auth/request-pq.js - About 55 mins 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

            gulp.task('test', function () {
                return gulp.src('./test/**/*test.js')
                    .pipe(mocha({reporter: 'mocha-better-spec-reporter', timeout: '90s'}));
            });
            Severity: Minor
            Found in gulpfile.js and 1 other location - About 50 mins to fix
            gulpfile.js on lines 16..19

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

            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

            gulp.task('cover', function () {
                return gulp.src('./test/**/*test.js')
                    .pipe(mocha({reporter: 'mocha-lcov-reporter', timeout: '90s'}));
            });
            Severity: Minor
            Found in gulpfile.js and 1 other location - About 50 mins to fix
            gulpfile.js on lines 11..14

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

            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

            Avoid deeply nested control flow statements.
            Open

                                if (b.repr[0] & 1) {
                                    c.addEquals(a);
                                    if (c.gt(num)) {
                                        c = c.subtract(num);
                                    }
            Severity: Major
            Found in lib/security/pq-finder.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if (a.gt(num)) {
                                      a = a.subtract(num);
                                  }
              Severity: Major
              Found in lib/security/pq-finder.js - About 45 mins to fix

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

                    var onError = function (e) {
                        logger.error('Error %s reading from %s', e.code, self._config);
                        if (callback) {
                            callback(e);
                        }
                Severity: Minor
                Found in lib/net/tcp-connection.js and 1 other location - About 40 mins to fix
                lib/net/tcp-connection.js on lines 173..178

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

                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

                        var onError = function (e) {
                            logger.error('Error %s disconnecting from %s', e.code, self._config);
                            if (callback) {
                                callback(e);
                            }
                Severity: Minor
                Found in lib/net/tcp-connection.js and 1 other location - About 40 mins to fix
                lib/net/tcp-connection.js on lines 131..136

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

                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 timeSynchronization has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function timeSynchronization(serverTime, requestDuration) {
                    var logger = getLogger('time.timeSynchronization');
                    var localTime = Math.floor(new Date().getTime() / 1000);
                    var response = requestDuration / 2;
                    if (logger.isDebugEnabled()) {
                Severity: Minor
                Found in lib/time.js - About 35 mins 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

                Severity
                Category
                Status
                Source
                Language