dalisoft/nanoexpress

View on GitHub
src/middlewares/http.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function handler has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    : async (req, res, config) => {
        let middlewareChainingTransferPreviousResult;
        for (const fn of prepared) {
          if (fn.simple || !fn.async) {
            fn(req, res, config, middlewareChainingTransferPreviousResult);
Severity: Major
Found in src/middlewares/http.js - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                    if (config._errorHandler) {
                      return config._errorHandler(middleware.error, req, res);
                    }
    Severity: Major
    Found in src/middlewares/http.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      if (config._errorHandler) {
                        return config._errorHandler(error, req, res);
                      }
      Severity: Major
      Found in src/middlewares/http.js - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

                      return;
        Severity: Major
        Found in src/middlewares/http.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return res.end(
                            `{"middleware_type":"${fn.type}",error":"${middleware.error.message}"}`
                          );
          Severity: Major
          Found in src/middlewares/http.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                      return res;
            Severity: Major
            Found in src/middlewares/http.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                return config._errorHandler(middleware.error, req, res);
              Severity: Major
              Found in src/middlewares/http.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                          return res;
                Severity: Major
                Found in src/middlewares/http.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return route(
                            req,
                            res,
                            config,
                            middlewareChainingTransferPreviousResult
                  Severity: Major
                  Found in src/middlewares/http.js - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status