enclose-io/compiler

View on GitHub
lts/lib/_http_incoming.js

Summary

Maintainability
F
1 wk
Test Coverage

Function matchKnownFields has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
Open

function matchKnownFields(field, lowercased) {
  switch (field.length) {
    case 3:
      if (field === 'Age' || field === 'age') return 'age';
      break;
Severity: Minor
Found in lts/lib/_http_incoming.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 matchKnownFields has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function matchKnownFields(field, lowercased) {
  switch (field.length) {
    case 3:
      if (field === 'Age' || field === 'age') return 'age';
      break;
Severity: Major
Found in lts/lib/_http_incoming.js - About 3 hrs to fix

    Function _addHeaderLine has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function _addHeaderLine(field, value, dest) {
      field = matchKnownFields(field);
      const flag = field.charCodeAt(0);
      if (flag === 0 || flag === 2) {
        field = field.slice(1);
    Severity: Minor
    Found in lts/lib/_http_incoming.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 IncomingMessage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function IncomingMessage(socket) {
      let streamOptions;
    
      if (socket) {
        streamOptions = {
    Severity: Minor
    Found in lts/lib/_http_incoming.js - About 1 hr to fix

      Function _addHeaderLines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function _addHeaderLines(headers, n) {
        if (headers && headers.length) {
          let dest;
          if (this.complete) {
            this.rawTrailers = headers;
      Severity: Minor
      Found in lts/lib/_http_incoming.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 '\u0000if-match';
      Severity: Major
      Found in lts/lib/_http_incoming.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return 'retry-after';
        Severity: Major
        Found in lts/lib/_http_incoming.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return 'if-unmodified-since';
          Severity: Major
          Found in lts/lib/_http_incoming.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return '\u0001';
            Severity: Major
            Found in lts/lib/_http_incoming.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return '\u0000accept-language';
              Severity: Major
              Found in lts/lib/_http_incoming.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      if (field === 'Referer' || field === 'referer') return 'referer';
                Severity: Major
                Found in lts/lib/_http_incoming.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return 'content-length';
                  Severity: Major
                  Found in lts/lib/_http_incoming.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return '\u0000content-encoding';
                    Severity: Major
                    Found in lts/lib/_http_incoming.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return 'if-modified-since';
                      Severity: Major
                      Found in lts/lib/_http_incoming.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return '\u0000x-forwarded-proto';
                        Severity: Major
                        Found in lts/lib/_http_incoming.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                if (field === 'Upgrade' || field === 'upgrade') return '\u0000upgrade';
                          Severity: Major
                          Found in lts/lib/_http_incoming.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return '\u0000connection';
                            Severity: Major
                            Found in lts/lib/_http_incoming.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return '\u0000cache-control';
                              Severity: Major
                              Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      if (field === 'Date' || field === 'date') return '\u0000date';
                                Severity: Major
                                Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        if (field === 'Expires' || field === 'expires') return 'expires';
                                  Severity: Major
                                  Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return '\u0000x-forwarded-host';
                                    Severity: Major
                                    Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                            if (field === 'Expect' || field === 'expect') return '\u0000expect';
                                      Severity: Major
                                      Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return 'content-type';
                                        Severity: Major
                                        Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                  return 'max-forwards';
                                          Severity: Major
                                          Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return 'authorization';
                                            Severity: Major
                                            Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return '\u0000if-none-match';
                                              Severity: Major
                                              Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return '\u0000x-forwarded-for';
                                                Severity: Major
                                                Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                        if (field === 'Accept' || field === 'accept') return '\u0000accept';
                                                  Severity: Major
                                                  Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                          if (field === 'Server' || field === 'server') return 'server';
                                                    Severity: Major
                                                    Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                              return 'last-modified';
                                                      Severity: Major
                                                      Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                return '\u0000accept-encoding';
                                                        Severity: Major
                                                        Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                  return '\u0000transfer-encoding';
                                                          Severity: Major
                                                          Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                  if (field === 'Vary' || field === 'vary') return '\u0000vary';
                                                            Severity: Major
                                                            Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                    if (field === 'Cookie' || field === 'cookie') return '\u0002cookie';
                                                              Severity: Major
                                                              Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                        return 'location';
                                                                Severity: Major
                                                                Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                          return 'proxy-authorization';
                                                                  Severity: Major
                                                                  Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                      return matchKnownFields(field.toLowerCase(), true);
                                                                    Severity: Major
                                                                    Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                              return 'user-agent';
                                                                      Severity: Major
                                                                      Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                              if (field === 'Origin' || field === 'origin') return '\u0000origin';
                                                                        Severity: Major
                                                                        Found in lts/lib/_http_incoming.js - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                              return '\u0000' + field;
                                                                          Severity: Major
                                                                          Found in lts/lib/_http_incoming.js - About 30 mins to fix

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

                                                                            function matchKnownFields(field, lowercased) {
                                                                              switch (field.length) {
                                                                                case 3:
                                                                                  if (field === 'Age' || field === 'age') return 'age';
                                                                                  break;
                                                                            Severity: Major
                                                                            Found in lts/lib/_http_incoming.js and 1 other location - About 5 days to fix
                                                                            current/lib/_http_incoming.js on lines 157..252

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

                                                                            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

                                                                            function _addHeaderLine(field, value, dest) {
                                                                              field = matchKnownFields(field);
                                                                              const flag = field.charCodeAt(0);
                                                                              if (flag === 0 || flag === 2) {
                                                                                field = field.slice(1);
                                                                            Severity: Major
                                                                            Found in lts/lib/_http_incoming.js and 1 other location - About 1 day to fix
                                                                            current/lib/_http_incoming.js on lines 263..285

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

                                                                            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

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

                                                                            function _addHeaderLines(headers, n) {
                                                                              if (headers && headers.length) {
                                                                                let dest;
                                                                                if (this.complete) {
                                                                                  this.rawTrailers = headers;
                                                                            Severity: Major
                                                                            Found in lts/lib/_http_incoming.js and 1 other location - About 5 hrs to fix
                                                                            current/lib/_http_incoming.js on lines 129..144

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

                                                                            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

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

                                                                            IncomingMessage.prototype._read = function _read(n) {
                                                                              if (!this._consuming) {
                                                                                this._readableState.readingMore = false;
                                                                                this._consuming = true;
                                                                              }
                                                                            Severity: Major
                                                                            Found in lts/lib/_http_incoming.js and 1 other location - About 3 hrs to fix
                                                                            current/lib/_http_incoming.js on lines 104..115

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

                                                                            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

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

                                                                            IncomingMessage.prototype._dump = function _dump() {
                                                                              if (!this._dumped) {
                                                                                this._dumped = true;
                                                                                // If there is buffered data, it may trigger 'data' events.
                                                                                // Remove 'data' event listeners explicitly.
                                                                            Severity: Major
                                                                            Found in lts/lib/_http_incoming.js and 1 other location - About 2 hrs to fix
                                                                            current/lib/_http_incoming.js on lines 290..298

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

                                                                            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

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

                                                                            IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {
                                                                              if (callback)
                                                                                this.on('timeout', callback);
                                                                              this.socket.setTimeout(msecs);
                                                                              return this;
                                                                            Severity: Major
                                                                            Found in lts/lib/_http_incoming.js and 1 other location - About 1 hr to fix
                                                                            current/lib/_http_incoming.js on lines 96..101

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

                                                                            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

                                                                            There are no issues that match your filters.

                                                                            Category
                                                                            Status