oleksiyk/kafka

View on GitHub

Showing 104 of 104 total issues

Function _send has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Producer.prototype._send = function (hash) {
    var self = this, task = self.queue[hash], data, result = [];

    delete self.queue[hash];

Severity: Major
Found in lib/producer.js - About 2 hrs to fix

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

    Connection.prototype.connect = function () {
        var self = this;
    
        if (self.connected) {
            return Promise.resolve();
    Severity: Minor
    Found in lib/connection.js - About 1 hr to fix

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

                  buffer = self.protocol.write().FetchRequest({
                      correlationId: correlationId,
                      clientId: self.options.clientId,
                      maxWaitTime: self.options.maxWaitTime,
                      minBytes: self.options.minBytes,
      Severity: Major
      Found in lib/client.js and 1 other location - About 1 hr to fix
      lib/client.js on lines 399..405

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

      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 buffer = self.protocol.write().ProduceRequest({
                          correlationId: correlationId,
                          clientId: self.options.clientId,
                          requiredAcks: self.options.requiredAcks,
                          timeout: self.options.timeout,
      Severity: Major
      Found in lib/client.js and 1 other location - About 1 hr to fix
      lib/client.js on lines 437..443

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

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

      Client.prototype.produceRequest = function (requests, codec) {
          var self = this, compressionPromises = [];
      
          function processPartition(pv, pk) {
              var _r = {
      Severity: Minor
      Found in lib/client.js - About 1 hr to fix

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

                this
                    .RequestHeader({
                        apiKey: globals.API_KEYS.OffsetRequest,
                        apiVersion: 0,
                        correlationId: data.correlationId,
        Severity: Major
        Found in lib/protocol/offset.js and 1 other location - About 1 hr to fix
        lib/protocol/fetch.js on lines 33..41

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

        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

                this
                    .RequestHeader({
                        apiKey: globals.API_KEYS.FetchRequest,
                        apiVersion: 0,
                        correlationId: data.correlationId,
        Severity: Major
        Found in lib/protocol/fetch.js and 1 other location - About 1 hr to fix
        lib/protocol/offset.js on lines 31..39

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

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

        BaseConsumer.prototype._fetch = function () {
            var self = this;
        
            return Promise.try(function () {
                var data = _(self.subscriptions).reject({ paused: true }).values().groupBy('leader').mapValues(function (v) {
        Severity: Minor
        Found in lib/base_consumer.js - About 1 hr to fix

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

          GroupConsumer.prototype._syncGroup = function () {
              var self = this;
          
              return Promise.try(function () {
                  if (self.memberId === self.leaderId) { // leader should generate group assignments
          Severity: Minor
          Found in lib/group_consumer.js - About 1 hr to fix

            Function send has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Producer.prototype.send = function (data, options) {
                var self = this, hash, promise, task;
            
                if (!Array.isArray(data)) {
                    data = [data];
            Severity: Minor
            Found in lib/producer.js - About 1 hr to fix

              Function _receive has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              Connection.prototype._receive = function (data) {
                  var length, correlationId;
              
                  if (!this.connected) {
                      return;
              Severity: Minor
              Found in lib/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 init has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Client.prototype.init = function () {
                  var self = this, p = Promise.resolve(), readFile = Promise.promisify(fs.readFile);
              
                  // deprecated but backward compatible ssl cert/key options
                  if (self.options.ssl.certFile && self.options.ssl.keyFile) {
              Severity: Minor
              Found in lib/client.js - About 1 hr to fix

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

                Client.prototype.updateMetadata = function (topicNames) {
                    var self = this;
                
                    if (self._updateMetadata_running.isPending()) {
                        return self._updateMetadata_running;
                Severity: Minor
                Found in lib/client.js - About 1 hr to fix

                  Function Client has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function Client(options) {
                      var self = this, logger;
                  
                      self.options = _.defaultsDeep(options || {}, {
                          clientId: 'no-kafka-client',
                  Severity: Minor
                  Found in lib/client.js - About 1 hr to fix

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

                        } else if (self.options.ssl.certStr && self.options.ssl.keyStr) {
                            self.options.ssl.cert = self.options.ssl.certStr;
                            self.options.ssl.key = self.options.ssl.keyStr;
                        } else if (process.env.KAFKA_CLIENT_CERT_STR && process.env.KAFKA_CLIENT_CERT_KEY_STR) {
                            self.options.ssl.cert = process.env.KAFKA_CLIENT_CERT_STR;
                    Severity: Major
                    Found in lib/client.js and 1 other location - About 1 hr to fix
                    lib/client.js on lines 91..100

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

                    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 (self.options.ssl.certFile && self.options.ssl.keyFile) {
                            self.options.ssl.cert = self.options.ssl.certFile;
                            self.options.ssl.key = self.options.ssl.keyFile;
                        } else if (self.options.ssl.certStr && self.options.ssl.keyStr) {
                            self.options.ssl.cert = self.options.ssl.certStr;
                    Severity: Major
                    Found in lib/client.js and 1 other location - About 1 hr to fix
                    lib/client.js on lines 94..100

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

                    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

                    Protocol.define('DescribeGroupResponse_GroupMemberItem', {
                        read: function () {
                            this
                                .string('memberId')
                                .string('clientId')
                    Severity: Major
                    Found in lib/protocol/admin.js and 1 other location - About 1 hr to fix
                    lib/protocol/group_membership.js on lines 26..35

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

                    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

                    Protocol.define('GroupCoordinatorResponse', {
                        read: function () {
                            this
                                .Int32BE('correlationId')
                                .ErrorCode('error')
                    Severity: Major
                    Found in lib/protocol/group_membership.js and 1 other location - About 1 hr to fix
                    lib/protocol/admin.js on lines 63..72

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

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

                    Client.prototype.fetchRequest = function (requests) {
                        var self = this;
                    
                        return self._waitMetadata().then(function () {
                            return Promise.all(_.map(requests, function (topics, leader) {
                    Severity: Minor
                    Found in lib/client.js - About 1 hr to fix

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

                          (function _try(_data, attempt) {
                              attempt = attempt || 1;
                      
                              return self._prepareProduceRequest(_data).then(function (requests) {
                                  var toRetry = _.filter(requests, _errored);
                      Severity: Minor
                      Found in lib/producer.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language