mjackson/mach

View on GitHub
modules/multipart/Parser.js

Summary

Maintainability
F
3 days
Test Coverage

Function execute has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
Open

Parser.prototype.execute = function (chunk) {
  var chunkLength = chunk.length,
      prevIndex = this.index,
      index = this.index,
      state = this.state,
Severity: Minor
Found in modules/multipart/Parser.js - About 1 day 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 execute has 166 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.execute = function (chunk) {
  var chunkLength = chunk.length,
      prevIndex = this.index,
      index = this.index,
      state = this.state,
Severity: Major
Found in modules/multipart/Parser.js - About 6 hrs to fix

    File Parser.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* jshint -W058 */
    var bodec = require('bodec');
    var Stream = require('bufferedstream');
    var Message = require('../Message');
    
    
    Severity: Minor
    Found in modules/multipart/Parser.js - About 2 hrs to fix

      Avoid deeply nested control flow statements.
      Open

            } else if (index - 1 == boundaryLength) {
              if (flags & F.PART_BOUNDARY) {
                index = 0;
                if (c == LF) {
                  // unset the PART_BOUNDARY flag
      Severity: Major
      Found in modules/multipart/Parser.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if (c != LF) {
                  return i;
                }
        Severity: Major
        Found in modules/multipart/Parser.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if (index === 0) {
                      this._dataCallback('partData', chunk, true, i);
                    }
          Severity: Major
          Found in modules/multipart/Parser.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                    if (c == CR) {
                      // CR = part boundary
                      flags |= F.PART_BOUNDARY;
                    } else if (c == HYPHEN) {
                      // HYPHEN = end boundary
            Severity: Major
            Found in modules/multipart/Parser.js - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                      return i;
              Severity: Major
              Found in modules/multipart/Parser.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  return chunkLength;
                Severity: Major
                Found in modules/multipart/Parser.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return i;
                  Severity: Major
                  Found in modules/multipart/Parser.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return i;
                    Severity: Major
                    Found in modules/multipart/Parser.js - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status