oleksiyk/kafka

View on GitHub

Showing 35 of 104 total issues

File client.js has 673 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var Promise     = require('./bluebird-configured');
var Connection  = require('./connection');
var Protocol    = require('./protocol');
Severity: Major
Found in lib/client.js - About 1 day to fix

    File group_consumer.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    var Promise      = require('./bluebird-configured');
    var _            = require('lodash');
    var BaseConsumer = require('./base_consumer');
    Severity: Minor
    Found in lib/group_consumer.js - About 2 hrs to fix

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

      'use strict';
      
      var Protocol = require('./index');
      var globals  = require('./globals');
      
      
      Severity: Minor
      Found in lib/protocol/group_membership.js - About 2 hrs to fix

        Function subscribe has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        BaseConsumer.prototype.subscribe = function (topic, partitions, options, handler) {
            var self = this;
        
            if (typeof partitions === 'function') {
                handler = partitions;
        Severity: Major
        Found in lib/base_consumer.js - About 2 hrs to fix

          Function fetchConsumerLag has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          GroupAdmin.prototype.fetchConsumerLag = function (groupId, offsetFetchRequestArgs) {
              return Promise.all([
                  this.client.offsetFetchRequestV1(groupId, offsetFetchRequestArgs),
                  this._fetchHighWaterMark(offsetFetchRequestArgs)
              ]).spread(function (offsets, highWaterMark) {
          Severity: Minor
          Found in lib/group_admin.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 _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

              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

                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

                            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

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

                                    self._updateMetadata_running = (function _try() {
                                        if (self.finished === true) {
                                            return Promise.resolve(null);
                                        }
                                
                                
                                Severity: Minor
                                Found in lib/client.js - About 1 hr to fix

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

                                    Function _prepareProduceRequest has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    Producer.prototype._prepareProduceRequest = function (data) {
                                        var self = this;
                                    
                                        return Promise.map(data, function (d) {
                                            delete d.error;
                                    Severity: Minor
                                    Found in lib/producer.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language