pharindoko/json-serverless

View on GitHub

Showing 27 of 84 total issues

Function run has 212 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async run() {
    const logo = await Helpers.generateLogo('json-serverless');
    this.log();
    this.log(`${chalk.blueBright(logo)}`);
    this.log();
Severity: Major
Found in packages/cli/src/commands/update-stack.ts - About 1 day to fix

    Function run has 181 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async run() {
        const logo = await Helpers.generateLogo('json-serverless');
        this.log();
        this.log(`${chalk.blueBright(logo)}`);
        this.log();
    Severity: Major
    Found in packages/cli/src/commands/create-stack.ts - About 7 hrs to fix

      File swaggerspec.ts has 410 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import _ from 'lodash';
      const listEndpoints = require('express-list-endpoints');
      import express from 'express';
      import {
        Info,
      Severity: Minor
      Found in packages/server/src/specifications/swagger/swaggerspec.ts - About 5 hrs to fix

        File create-stack.ts has 377 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import * as inquirer from 'inquirer';
        import fs from 'fs-extra';
        import { Command, flags } from '@oclif/command';
        import Listr = require('listr');
        import { AppConfig, LogLevel } from 'json-serverless-lib';
        Severity: Minor
        Found in packages/cli/src/commands/create-stack.ts - About 5 hrs to fix

          File helpers.ts has 353 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import fs from 'fs-extra';
          import * as path from 'path';
          const util = require('util');
          const exec = util.promisify(require('child_process').exec);
          import figlet from 'figlet';
          Severity: Minor
          Found in packages/cli/src/actions/helpers.ts - About 4 hrs to fix

            Function createCLIOutput has 90 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static createCLIOutput(
                slsinfo: string,
                appConfig: AppConfig,
                stage: string,
                s3bucketPath?: string,
            Severity: Major
            Found in packages/cli/src/actions/helpers.ts - About 3 hrs to fix

              File update-stack.ts has 309 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import fs from 'fs-extra';
              import { Command, flags } from '@oclif/command';
              import Listr = require('listr');
              import * as path from 'path';
              import { Helpers } from '../actions/helpers';
              Severity: Minor
              Found in packages/cli/src/commands/update-stack.ts - About 3 hrs to fix

                Function setupRoutes has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  protected async setupRoutes(
                    db: {},
                    middlewares,
                    router,
                    appConfig: AppConfig
                Severity: Major
                Found in packages/server/src/app/core.app.ts - About 2 hrs to fix

                  Function run has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                    async run() {
                      const logo = await Helpers.generateLogo('json-serverless');
                      this.log();
                      this.log(`${chalk.blueBright(logo)}`);
                      this.log();
                  Severity: Minor
                  Found in packages/cli/src/commands/update-stack.ts - About 2 hrs 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 getQueryParameterSchema has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    getQueryParameterSchema(): QueryParameter[] {
                      return [
                        {
                          name: '_page',
                          in: 'query',
                  Severity: Major
                  Found in packages/server/src/specifications/swagger/swaggerspec.ts - About 2 hrs to fix

                    Function run has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async run() {
                        const logo = await Helpers.generateLogo('json-serverless');
                        this.log();
                        this.log(`${chalk.blueBright(logo)}`);
                        this.log();
                    Severity: Minor
                    Found in packages/cli/src/commands/create-stack.ts - About 2 hrs 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 createCLIOutput has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private createCLIOutput(
                        swagger: boolean,
                        apikeyauth: boolean,
                        apiRoute: string,
                        apiKey: string
                    Severity: Major
                    Found in packages/cli/src/commands/run.ts - About 2 hrs to fix

                      Function initSpec has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        initSpec(
                          readOnly: boolean,
                          basePath: string,
                          routePath: string,
                          specPath: string
                      Severity: Major
                      Found in packages/server/src/specifications/swagger/swaggerspec.ts - About 2 hrs to fix

                        Function parseServerlessInfo has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private static parseServerlessInfo(slsinfo: string) {
                            const rows = JSON.stringify(slsinfo).split('\\n') as any[];
                            const createKeyValues = rows.map((x, i, rows) => {
                              if (x.startsWith('  ANY -')) {
                                x = {
                        Severity: Minor
                        Found in packages/cli/src/actions/helpers.ts - About 1 hr to fix

                          Function parseServerlessInfo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                            private static parseServerlessInfo(slsinfo: string) {
                              const rows = JSON.stringify(slsinfo).split('\\n') as any[];
                              const createKeyValues = rows.map((x, i, rows) => {
                                if (x.startsWith('  ANY -')) {
                                  x = {
                          Severity: Minor
                          Found in packages/cli/src/actions/helpers.ts - 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 run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async run() {
                              const logo = await Helpers.generateLogo('json-serverless');
                              this.log(`${chalk.blueBright(logo)}`);
                              this.log();
                              const { args, flags } = this.parse(Run);
                          Severity: Minor
                          Found in packages/cli/src/commands/run.ts - About 1 hr to fix

                            Function setupRoutes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              protected async setupRoutes(
                                db: {},
                                middlewares,
                                router,
                                appConfig: AppConfig
                            Severity: Minor
                            Found in packages/server/src/app/core.app.ts - 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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              validate(): RuleEvent[] {
                                try {
                                  if (this.jsonObject) {
                                    const ajvObject = new ajv();
                                    const result = ajvObject.validate(requestSchema, this.jsonObject);
                            Severity: Minor
                            Found in packages/server/src/validations/validationrule.ts - 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 task has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    task: async (ctx, task) => {
                                      if (
                                        apiKeyValue &&
                                        appConfig.enableApiKeyAuth !== flags.apikeyauth &&
                                        flags.apikeyauth
                            Severity: Minor
                            Found in packages/cli/src/commands/update-stack.ts - About 1 hr to fix

                              Function constructor has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                constructor(server: express.Express, apiKey: string) {
                                  this.server = server;
                                  this.apiKey = apiKey;
                                  this.authenticationMiddleware = (whiteList: string[]) => async (
                                    req,
                              Severity: Minor
                              Found in packages/server/src/auth/apikey.strategy.ts - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language