nanoexpress/nanoexpress

View on GitHub

Showing 49 of 55 total issues

Consider simplifying this complex logical expression.
Open

              if (
                !isRaw &&
                !res._modifiedEnd &&
                (!res.writeHead.notModified ||
                  (res.statusCode && res.statusCode !== 200) ||
Severity: Major
Found in src/Route.js - About 40 mins to fix

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

    export default function writeHeaders(headers) {
      for (const header in headers) {
        const value = headers[header];
        if (value) {
          if (value.splice) {
    Severity: Minor
    Found in src/response-proto/http/header-chunks/write-headers.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

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

    export default function pipe(stream, size, compressed = false) {
      const { __request: req } = this;
      const { onAborted, headers, responseHeaders } = req;
      let isAborted = false;
    
    
    Severity: Minor
    Found in src/response-proto/http/response-chunks/pipe.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

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

    export default function setHeaders(headers) {
      for (const header in headers) {
        if (this._headers) {
          const currentHeader = this._headers[header];
          if (currentHeader !== undefined || currentHeader !== null) {
    Severity: Minor
    Found in src/response-proto/http/header-chunks/set-headers.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 null;
    Severity: Major
    Found in src/compilers/route.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                    return routeFunction(req, res);
      Severity: Major
      Found in src/Route.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return compiled;
        Severity: Major
        Found in src/compilers/route.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return null;
          Severity: Major
          Found in src/compilers/route.js - About 30 mins to fix

            Function address has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              get address() {
                const { _config: config } = this;
                let address = '';
                if (config.host) {
                  address += config.https ? 'https://' : 'http://';
            Severity: Minor
            Found in src/App.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

            Severity
            Category
            Status
            Source
            Language