oleksiyk/kafka

View on GitHub

Showing 104 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

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

    Protocol.define('OffsetCommitRequestV1', {
        write: function (data) { // { groupId, generationId, memberId,  topics }
            this
                .RequestHeader({
                    apiKey: globals.API_KEYS.OffsetCommitRequest,
    Severity: Major
    Found in lib/protocol/offset_commit_fetch.js and 1 other location - About 4 hrs to fix
    lib/protocol/group_membership.js on lines 157..171

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

    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('SyncGroupRequest', {
        write: function (data) { // { groupId generationId memberId groupAssignment }
            this
                .RequestHeader({
                    apiKey: globals.API_KEYS.SyncGroupRequest,
    Severity: Major
    Found in lib/protocol/group_membership.js and 1 other location - About 4 hrs to fix
    lib/protocol/offset_commit_fetch.js on lines 68..82

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

    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

        write: function (data) { // {partition, messageSet}
            var _o1, _o2;
            this.Int32BE(data.partition);
            _o1 = this.offset;
            this
    Severity: Major
    Found in lib/protocol/produce.js and 1 other location - About 4 hrs to fix
    lib/protocol/common.js on lines 175..186

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

    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

        write: function (value) { // {offset, message}
            var _o1, _o2;
            this.KafkaOffset(value.offset);
            _o1 = this.offset;
            this
    Severity: Major
    Found in lib/protocol/common.js and 1 other location - About 4 hrs to fix
    lib/protocol/produce.js on lines 13..24

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

    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.JoinGroupRequest,
                    apiVersion: 0,
                    correlationId: data.correlationId,
    Severity: Major
    Found in lib/protocol/group_membership.js and 1 other location - About 3 hrs to fix
    lib/protocol/offset_commit_fetch.js on lines 87..98

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

    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.OffsetCommitRequest,
                    apiVersion: 2,
                    correlationId: data.correlationId,
    Severity: Major
    Found in lib/protocol/offset_commit_fetch.js and 1 other location - About 3 hrs to fix
    lib/protocol/group_membership.js on lines 49..60

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

    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('JoinGroupResponse', {
        read: function () {
            this
                .Int32BE('correlationId')
                .ErrorCode('error')
    Severity: Major
    Found in lib/protocol/group_membership.js and 1 other location - About 2 hrs to fix
    lib/protocol/group_membership.js on lines 134..145

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

    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('JoinConsumerGroupResponse', {
        read: function () {
            this
                .Int32BE('correlationId')
                .ErrorCode('error')
    Severity: Major
    Found in lib/protocol/group_membership.js and 1 other location - About 2 hrs to fix
    lib/protocol/group_membership.js on lines 110..121

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

    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

    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

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

                  return connection.send(correlationId, buffer).then(function (responseBuffer) {
                      var result = self.protocol.read(responseBuffer).JoinConsumerGroupResponse().result;
                      if (result.error) {
                          throw result.error;
                      }
          Severity: Major
          Found in lib/client.js and 4 other locations - About 2 hrs to fix
          lib/client.js on lines 610..616
          lib/client.js on lines 669..675
          lib/client.js on lines 693..699
          lib/client.js on lines 715..721

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

          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 5 locations. Consider refactoring.
          Open

                  return connection.send(correlationId, buffer).then(function (responseBuffer) {
                      var result = self.protocol.read(responseBuffer).HeartbeatResponse().result;
                      if (result.error) {
                          throw result.error;
                      }
          Severity: Major
          Found in lib/client.js and 4 other locations - About 2 hrs to fix
          lib/client.js on lines 610..616
          lib/client.js on lines 646..652
          lib/client.js on lines 693..699
          lib/client.js on lines 715..721

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

          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 5 locations. Consider refactoring.
          Open

                  return connection.send(correlationId, buffer).then(function (responseBuffer) {
                      var result = self.protocol.read(responseBuffer).GroupCoordinatorResponse().result;
                      if (result.error) {
                          throw result.error;
                      }
          Severity: Major
          Found in lib/client.js and 4 other locations - About 2 hrs to fix
          lib/client.js on lines 646..652
          lib/client.js on lines 669..675
          lib/client.js on lines 693..699
          lib/client.js on lines 715..721

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

          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 5 locations. Consider refactoring.
          Open

                  return connection.send(correlationId, buffer).then(function (responseBuffer) {
                      var result = self.protocol.read(responseBuffer).LeaveGroupResponse().result;
                      if (result.error) {
                          throw result.error;
                      }
          Severity: Major
          Found in lib/client.js and 4 other locations - About 2 hrs to fix
          lib/client.js on lines 610..616
          lib/client.js on lines 646..652
          lib/client.js on lines 669..675
          lib/client.js on lines 693..699

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

          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

          SimpleConsumer.prototype.fetchOffset = function (commits) {
              var self = this;
          
              return self._prepareOffsetRequest('fetch', commits).then(function (data) {
                  return self.client.offsetFetchRequestV0(self.options.groupId, data);
          Severity: Major
          Found in lib/simple_consumer.js and 1 other location - About 2 hrs to fix
          lib/simple_consumer.js on lines 67..73

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

          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

          SimpleConsumer.prototype.commitOffset = function (commits) {
              var self = this;
          
              return self._prepareOffsetRequest('commit', commits).then(function (data) {
                  return self.client.offsetCommitRequestV0(self.options.groupId, data);
          Severity: Major
          Found in lib/simple_consumer.js and 1 other location - About 2 hrs to fix
          lib/simple_consumer.js on lines 81..87

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

          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 5 locations. Consider refactoring.
          Open

                  return connection.send(correlationId, buffer).then(function (responseBuffer) {
                      var result = self.protocol.read(responseBuffer).SyncConsumerGroupResponse().result;
                      if (result.error) {
                          throw result.error;
                      }
          Severity: Major
          Found in lib/client.js and 4 other locations - About 2 hrs to fix
          lib/client.js on lines 610..616
          lib/client.js on lines 646..652
          lib/client.js on lines 669..675
          lib/client.js on lines 715..721

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

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

          Severity
          Category
          Status
          Source
          Language