raveljs/ravel

View on GitHub

Showing 47 of 59 total issues

Function middleware has 35 lines of code (exceeds 30 allowed). Consider refactoring.
Open

  middleware () {
    this[sRouteTree].sort();
    return async (ctx, next) => {
      if (ctx.method === 'OPTIONS') {
        ctx.status = 200;
Severity: Minor
Found in lib/core/router.js - About 1 hr to fix

    Function init has 33 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

      init () {
        // set up websocket on server, with session cookie generation
        this.wss = new WebSocket.Server({
          noServer: true,
          maxPayload: this.ravelApp.get('max websocket payload bytes')
    Severity: Minor
    Found in lib/core/websocket.js - About 1 hr to fix

      Function scan has 33 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

        Ravel.prototype.scan = function (...basePaths) {
          for (const basePath of basePaths) {
            const absPath = upath.toUnix(upath.isAbsolute(basePath)
              ? basePath
              : upath.toUnix(upath.posix.join(this.cwd, basePath)));
      Severity: Minor
      Found in lib/core/scan.js - About 1 hr to fix

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

          static compare (lNode, rNode) {
            // catch-all routes have the lowest priority
            if (!lNode.catchAll && rNode.catchAll) {
              return -1;
            } else if (lNode.catchAll && !rNode.catchAll) {
        Severity: Minor
        Found in lib/util/route-tree.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 getModule has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          getModule (moduleMap, moduleName) {
            if (moduleMap[moduleName] !== undefined) {
              // if the requested module is in our map of predefined valid stuff
              return moduleMap[moduleName];
            } else if (this[sRavelInstance][coreSymbols.moduleFactories][moduleName] !== undefined) {
        Severity: Minor
        Found in lib/core/injector.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 sOpenConnections has 32 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

        TransactionFactory.prototype[sOpenConnections] = function (providerNames, closers) {
          // guarantee provider names are unique
          let uniqueProviderNames = new Set();
          providerNames.forEach(n => uniqueProviderNames.add(n));
          uniqueProviderNames = Array.from(uniqueProviderNames);
        Severity: Minor
        Found in lib/db/database.js - About 1 hr to fix

          Function authconfig has 31 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

          function authconfig (target) {
            Metadata.putClassMeta(target.prototype, '@authconfig', 'enabled', true);
          
            if (!target.prototype.serializeUser) {
              target.prototype.serializeUser = function (profile) { // eslint-disable-line no-unused-vars
          Severity: Minor
          Found in lib/auth/decorators/authconfig.js - About 1 hr to fix

            Function createClient has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function createClient (ravelInstance, restrict = true) {
              const localRedis = ravelInstance.get('redis port') === undefined || ravelInstance.get('redis host') === undefined;
              ravelInstance.on('post init', () => {
                ravelInstance.$log.info(localRedis
                  ? 'Using in-memory key-value store. Please do not scale this app horizontally.'
            Severity: Minor
            Found in lib/util/kvstore.js - About 45 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

            Consider simplifying this complex logical expression.
            Open

              } else if (options.okCode === httpCodes.PARTIAL_CONTENT && response.body !== undefined &&
                         options !== undefined && options.start !== undefined &&
                         options.end !== undefined && options.count !== undefined) {
                response.set('Content-Range', 'items ' + options.start + '-' + options.end + '/' + options.count);
              }
            Severity: Major
            Found in lib/util/rest.js - About 40 mins to fix

              Function buildRoute has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function buildRoute (ravelInstance, routes, koaRouter, methodName, meta) {
              Severity: Minor
              Found in lib/core/routes.js - About 35 mins to fix

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

                const inject = function (...rest) {
                  return function (target) {
                    if (rest.length === 0) {
                      throw new $err.NotFound(`Empty @inject supplied on ${typeof target}`);
                    }
                Severity: Minor
                Found in lib/core/decorators/inject.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 authenticated has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function authenticated (...args) {
                  if (args.length === 3 && typeof args[0].constructor === 'function') {
                    Metadata.putMethodMeta(args[0], args[1], '@authenticated', 'config', Object.create(null));
                  } else if (args.length === 1 && typeof args[0] === 'function') {
                    // handle @authenticated at the class-level without arguments
                Severity: Minor
                Found in lib/auth/decorators/authenticated.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 exports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function (ravelInstance, router) {
                  /**
                   * Retrieve the first registered Module which is decorated with `@authconfig`.
                   *
                   * @returns {object} The first `@authconfig` `Module`.
                Severity: Minor
                Found in lib/auth/passport_init.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 1;
                Severity: Major
                Found in lib/util/route-tree.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return 0;
                  Severity: Major
                  Found in lib/util/route-tree.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return new RouteTreeResult(keyValues, child.middleware, child.composedMiddleware);
                    Severity: Major
                    Found in lib/util/route-tree.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return 0;
                      Severity: Major
                      Found in lib/util/route-tree.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return -1;
                        Severity: Major
                        Found in lib/util/route-tree.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                return 1;
                          Severity: Major
                          Found in lib/util/route-tree.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return;
                            Severity: Major
                            Found in lib/util/response_cache.js - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language