pharindoko/json-serverless

View on GitHub

Showing 84 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

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

              private async getDescription(description: string) {
                let stackDescription: string | undefined;
                if (description) {
                  stackDescription = description;
                } else {
            Severity: Major
            Found in packages/cli/src/commands/create-stack.ts and 1 other location - About 4 hrs to fix
            packages/cli/src/commands/create-stack.ts on lines 361..375

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

            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

              private async getApiName(name?: string) {
                let stackName: string | undefined;
                if (name) {
                  stackName = name;
                } else {
            Severity: Major
            Found in packages/cli/src/commands/create-stack.ts and 1 other location - About 4 hrs to fix
            packages/cli/src/commands/create-stack.ts on lines 343..359

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

            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 5 locations. Consider refactoring.
            Open

                      if (spec.paths[path].put) {
                        const operation = spec.paths[path].put as Operation;
                        Object.assign(
                          operation,
                          this.getDefaultSchemaProperties(definition)
            Severity: Major
            Found in packages/server/src/specifications/swagger/swaggerspec.ts and 4 other locations - About 3 hrs to fix
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 322..335
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 336..349
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 350..363
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 403..416

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

            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 5 locations. Consider refactoring.
            Open

                      if (spec.paths[path].post) {
                        const operation = spec.paths[path].post as Operation;
                        Object.assign(
                          operation,
                          this.getDefaultSchemaProperties(definition)
            Severity: Major
            Found in packages/server/src/specifications/swagger/swaggerspec.ts and 4 other locations - About 3 hrs to fix
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 336..349
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 350..363
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 389..402
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 403..416

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

            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 5 locations. Consider refactoring.
            Open

                      if (spec.paths[path].put) {
                        const operation = spec.paths[path].put as Operation;
                        Object.assign(
                          operation,
                          this.getDefaultSchemaProperties(definition)
            Severity: Major
            Found in packages/server/src/specifications/swagger/swaggerspec.ts and 4 other locations - About 3 hrs to fix
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 322..335
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 350..363
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 389..402
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 403..416

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

            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 5 locations. Consider refactoring.
            Open

                      if (spec.paths[path].patch) {
                        const operation = spec.paths[path].patch as Operation;
                        Object.assign(
                          operation,
                          this.getDefaultSchemaProperties(definition)
            Severity: Major
            Found in packages/server/src/specifications/swagger/swaggerspec.ts and 4 other locations - About 3 hrs to fix
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 322..335
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 336..349
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 350..363
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 389..402

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

            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 5 locations. Consider refactoring.
            Open

                      if (spec.paths[path].patch) {
                        const operation = spec.paths[path].patch as Operation;
                        Object.assign(
                          operation,
                          this.getDefaultSchemaProperties(definition)
            Severity: Major
            Found in packages/server/src/specifications/swagger/swaggerspec.ts and 4 other locations - About 3 hrs to fix
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 322..335
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 336..349
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 389..402
            packages/server/src/specifications/swagger/swaggerspec.ts on lines 403..416

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

            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

            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

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

                    try {
                      const identity = await AWSActions.checkValidAWSIdentity();
                      this.log(`${chalk.green('AWS Account: ' + identity.Account)}`);
                    } catch (error) {
                      this.error(`${chalk.red(error.message)}`);
                Severity: Major
                Found in packages/cli/src/commands/update-stack.ts and 1 other location - About 3 hrs to fix
                packages/cli/src/commands/create-stack.ts on lines 333..338

                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

                    try {
                      const identity = await AWSActions.checkValidAWSIdentity();
                      this.log(`${chalk.green('AWS Account: ' + identity.Account)}`);
                    } catch (error) {
                      this.error(`${chalk.red(error.message)}`);
                Severity: Major
                Found in packages/cli/src/commands/create-stack.ts and 1 other location - About 3 hrs to fix
                packages/cli/src/commands/update-stack.ts on lines 115..120

                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

                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

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

                            {
                              title: 'Install Dependencies',
                              task: async (task) => {
                                if (process.env.NODE_ENV != 'local') {
                                  task.output = 'INSTALL DEPENDENCIES';
                    Severity: Major
                    Found in packages/cli/src/commands/create-stack.ts and 1 other location - About 2 hrs to fix
                    packages/cli/src/commands/update-stack.ts on lines 252..267

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language