Showing 35 of 104 total issues
File client.js
has 673 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict';
var Promise = require('./bluebird-configured');
var Connection = require('./connection');
var Protocol = require('./protocol');
File group_consumer.js
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict';
var Promise = require('./bluebird-configured');
var _ = require('lodash');
var BaseConsumer = require('./base_consumer');
File group_membership.js
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict';
var Protocol = require('./index');
var globals = require('./globals');
Function subscribe
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
BaseConsumer.prototype.subscribe = function (topic, partitions, options, handler) {
var self = this;
if (typeof partitions === 'function') {
handler = partitions;
Function fetchConsumerLag
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
GroupAdmin.prototype.fetchConsumerLag = function (groupId, offsetFetchRequestArgs) {
return Promise.all([
this.client.offsetFetchRequestV1(groupId, offsetFetchRequestArgs),
this._fetchHighWaterMark(offsetFetchRequestArgs)
]).spread(function (offsets, highWaterMark) {
- Read upRead up
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
Open
Producer.prototype._send = function (hash) {
var self = this, task = self.queue[hash], data, result = [];
delete self.queue[hash];
Function connect
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Connection.prototype.connect = function () {
var self = this;
if (self.connected) {
return Promise.resolve();
Function produceRequest
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Client.prototype.produceRequest = function (requests, codec) {
var self = this, compressionPromises = [];
function processPartition(pv, pk) {
var _r = {
Function _fetch
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
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) {
Function _syncGroup
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
GroupConsumer.prototype._syncGroup = function () {
var self = this;
return Promise.try(function () {
if (self.memberId === self.leaderId) { // leader should generate group assignments
Function send
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Producer.prototype.send = function (data, options) {
var self = this, hash, promise, task;
if (!Array.isArray(data)) {
data = [data];
Function _receive
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
Connection.prototype._receive = function (data) {
var length, correlationId;
if (!this.connected) {
return;
- Read upRead up
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
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) {
Function updateMetadata
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Client.prototype.updateMetadata = function (topicNames) {
var self = this;
if (self._updateMetadata_running.isPending()) {
return self._updateMetadata_running;
Function Client
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Client(options) {
var self = this, logger;
self.options = _.defaultsDeep(options || {}, {
clientId: 'no-kafka-client',
Function fetchRequest
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Client.prototype.fetchRequest = function (requests) {
var self = this;
return self._waitMetadata().then(function () {
return Promise.all(_.map(requests, function (topics, leader) {
Function _try
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
(function _try(_data, attempt) {
attempt = attempt || 1;
return self._prepareProduceRequest(_data).then(function (requests) {
var toRetry = _.filter(requests, _errored);
Function _try
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
self._updateMetadata_running = (function _try() {
if (self.finished === true) {
return Promise.resolve(null);
}
Function _receive
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Connection.prototype._receive = function (data) {
var length, correlationId;
if (!this.connected) {
return;
Function _prepareProduceRequest
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Producer.prototype._prepareProduceRequest = function (data) {
var self = this;
return Promise.map(data, function (d) {
delete d.error;