oleksiyk/kafka

View on GitHub
lib/producer.js

Summary

Maintainability
B
6 hrs
Test Coverage

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

          Function send has a Cognitive Complexity of 6 (exceeds 5 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 25 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

          There are no issues that match your filters.

          Category
          Status