haraka/message-stream

View on GitHub

Showing 18 of 21 total issues

File index.js has 417 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const EventEmitter = require('events').EventEmitter;
const fs     = require('fs');
const Stream = require('stream').Stream;
Severity: Minor
Found in index.js - About 6 hrs to fix

    Function _write has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

      _write (data) {
        const self = this;
        if (data) {
          this.buffered += data.length;
          this.total_buffered += data.length;
    Severity: Minor
    Found in index.js - About 4 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 add_line has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      add_line (line) {
        const self = this;
    
        if (typeof line === 'string') {
          line = Buffer.from(line);
    Severity: Minor
    Found in index.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 _write has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _write (data) {
        const self = this;
        if (data) {
          this.buffered += data.length;
          this.total_buffered += data.length;
    Severity: Major
    Found in index.js - About 2 hrs to fix

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

        _read () {
          const self = this;
          if (!this.end_called) {
            throw new Error('end not called!');
          }
      Severity: Minor
      Found in index.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 pipe has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        pipe (destination, options = {}) {
          const self = this;
          if (this.in_pipe) {
            throw new Error('Cannot pipe while currently piping');
          }
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function process_buf has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          process_buf (buf) {
            let offset = 0;
            while ((offset = indexOfLF(buf)) !== -1) {
              let line = buf.slice(0, offset+1);
              buf = buf.slice(line.length);
        Severity: Minor
        Found in index.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 _read has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _read () {
            const self = this;
            if (!this.end_called) {
              throw new Error('end not called!');
            }
        Severity: Minor
        Found in index.js - About 1 hr to fix

          Function constructor has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor (cfg = {}, id, headers) {
              super();
              if (!id) throw new Error('id required');
              this.uuid = id;
              this.write_ce = null;
          Severity: Minor
          Found in index.js - About 1 hr to fix

            Function add_line has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              add_line (line) {
                const self = this;
            
                if (typeof line === 'string') {
                  line = Buffer.from(line);
            Severity: Minor
            Found in index.js - About 1 hr to fix

              Function process_buf has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                process_buf (buf) {
                  let offset = 0;
                  while ((offset = indexOfLF(buf)) !== -1) {
                    let line = buf.slice(0, offset+1);
                    buf = buf.slice(line.length);
              Severity: Minor
              Found in index.js - About 1 hr to fix

                Function fill has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  fill (input) {
                    if (typeof input === 'string') {
                      input = Buffer.from(input);
                    }
                
                
                Severity: Minor
                Found in index.js - About 1 hr to fix

                  Function fill has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    fill (input) {
                      if (typeof input === 'string') {
                        input = Buffer.from(input);
                      }
                  
                  
                  Severity: Minor
                  Found in index.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 pipe has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    pipe (destination, options = {}) {
                      const self = this;
                      if (this.in_pipe) {
                        throw new Error('Cannot pipe while currently piping');
                      }
                  Severity: Minor
                  Found in index.js - About 35 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

                  Avoid too many return statements within this function.
                  Open

                        return true;
                  Severity: Major
                  Found in index.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return self._write();
                    Severity: Major
                    Found in index.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          if (!this.fd) return false;
                      Severity: Major
                      Found in index.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return false;
                        Severity: Major
                        Found in index.js - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language