drg-adaptive/serverless-swagger-api

View on GitHub

Showing 6 of 6 total issues

File index.ts has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as Serverless from "serverless";
import Plugin = require("serverless/classes/Plugin");
import * as path from "path";
import * as AWS from "aws-sdk";

Severity: Minor
Found in src/index.ts - About 5 hrs to fix

    Function createRestApi has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private createRestApi(key: string, restApi: APIDefinition) {
        const resources = this.serverless.service.provider
          .compiledCloudFormationTemplate.Resources;
        const stage = restApi.Stage || this.serverless.service.provider.stage;
        const service = this.serverless.service.getServiceName();
    Severity: Major
    Found in src/index.ts - About 4 hrs to fix

      Function createRestApi has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        private createRestApi(key: string, restApi: APIDefinition) {
          const resources = this.serverless.service.provider
            .compiledCloudFormationTemplate.Resources;
          const stage = restApi.Stage || this.serverless.service.provider.stage;
          const service = this.serverless.service.getServiceName();
      Severity: Minor
      Found in src/index.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 updateApiDeployments has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private async updateApiDeployments() {
          const aws = this.serverless.getProvider("aws");
          const region = aws.getRegion();
          const options = this.pluginOptions;
      
      
      Severity: Major
      Found in src/index.ts - About 2 hrs to fix

        Function createServiceRole has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private createServiceRole(
            stackName: string,
            service: string,
            key: string,
            functionNames: any[]
        Severity: Minor
        Found in src/index.ts - About 1 hr to fix

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

            private async updateApiDeployments() {
              const aws = this.serverless.getProvider("aws");
              const region = aws.getRegion();
              const options = this.pluginOptions;
          
          
          Severity: Minor
          Found in src/index.ts - 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