apiaryio/fury-adapter-swagger

View on GitHub

Showing 50 of 64 total issues

File parser.js has 1198 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// The main Swagger parsing component that outputs refract.

import _ from 'lodash';
import { sep } from 'path';
import yaml from 'js-yaml';
Severity: Major
Found in src/parser.js - About 3 days to fix

    Function generateElement has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

      generateElement(schema) {
        const {
          String: StringElement,
          Number: NumberElement,
          Boolean: BooleanElement,
    Severity: Minor
    Found in src/schema.js - About 6 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

    Parser has 46 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Parser {
      constructor({ minim, source, generateSourceMap }) {
        // Parser options
        this.minim = minim;
        this.source = source;
    Severity: Minor
    Found in src/parser.js - About 6 hrs to fix

      Function parse has 123 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        parse(done) {
          const {
            Category, ParseResult, SourceMap,
          } = this.minim.elements;
          const swaggerParser = new SwaggerParser();
      Severity: Major
      Found in src/parser.js - About 4 hrs to fix

        Function getPosition has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

          getPosition(path) {
            const pieces = _.isArray(path) ? [].concat(path) : path.split('.');
            let end;
            let node = this.root;
            let piece = pieces.shift();
        Severity: Minor
        Found in src/ast.js - About 4 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 generateElement has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          generateElement(schema) {
            const {
              String: StringElement,
              Number: NumberElement,
              Boolean: BooleanElement,
        Severity: Major
        Found in src/schema.js - About 3 hrs to fix

          Function convertSubSchema has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          function convertSubSchema(schema, references, swagger) {
            if (schema.$ref) {
              references.push(schema.$ref);
              return { $ref: schema.$ref };
            }
          Severity: Minor
          Found in src/json-schema.js - About 3 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 handleSwaggerExampleRequest has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            handleSwaggerExampleRequest(
              transaction, methodValue, transitionParams, resourceParams,
              requestContentType, responseContentType, contentTypeFromProduces,
            ) {
              let contentType = requestContentType;
          Severity: Major
          Found in src/parser.js - About 3 hrs to fix

            Function handleSwaggerMethod has 69 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              handleSwaggerMethod(resource, href, resourceParams, methodValue, method) {
                const { Copy, Transition } = this.minim.elements;
                const transition = new Transition();
            
                resource.content.push(transition);
            Severity: Major
            Found in src/parser.js - About 2 hrs to fix

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

                convertParameterToElement(parameter, setAttributes = false) {
                  const { Array: ArrayElement, Enum: EnumElement } = this.minim.elements;
              
                  const Type = this.typeForParameter(parameter);
                  const schema = this.schemaForParameterValue(parameter);
              Severity: Minor
              Found in src/parser.js - 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 convertParameterToElement has 67 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                convertParameterToElement(parameter, setAttributes = false) {
                  const { Array: ArrayElement, Enum: EnumElement } = this.minim.elements;
              
                  const Type = this.typeForParameter(parameter);
                  const schema = this.schemaForParameterValue(parameter);
              Severity: Major
              Found in src/parser.js - About 2 hrs to fix

                Function handleSwaggerExampleResponse has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  handleSwaggerExampleResponse(
                    transaction, methodValue, responseValue,
                    statusCode, responseBody, contentType,
                  ) {
                    const { Asset, Copy } = this.minim.elements;
                Severity: Major
                Found in src/parser.js - About 2 hrs to fix

                  Function convertSubSchema has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function convertSubSchema(schema, references, swagger) {
                    if (schema.$ref) {
                      references.push(schema.$ref);
                      return { $ref: schema.$ref };
                    }
                  Severity: Major
                  Found in src/json-schema.js - About 2 hrs to fix

                    Function handleSwaggerAuth has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      handleSwaggerAuth() {
                        const { Category, AuthScheme } = this.minim.elements;
                        const schemes = [];
                    
                        if (this.swagger.securityDefinitions) {
                    Severity: Major
                    Found in src/parser.js - About 2 hrs to fix

                      Function findReferences has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function findReferences(schema) {
                        if (schema.$ref) {
                          return [schema.$ref];
                        }
                      
                      
                      Severity: Minor
                      Found in src/json-schema.js - 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 handleSwaggerPath has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        handleSwaggerPath(pathValue, href) {
                          const { Copy, Resource } = this.minim.elements;
                          const resource = new Resource();
                      
                          this.withPath('paths', href, () => {
                      Severity: Minor
                      Found in src/parser.js - About 1 hr to fix

                        Function getPosition has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          getPosition(path) {
                            const pieces = _.isArray(path) ? [].concat(path) : path.split('.');
                            let end;
                            let node = this.root;
                            let piece = pieces.shift();
                        Severity: Minor
                        Found in src/ast.js - About 1 hr to fix

                          Function findReferences has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function findReferences(schema) {
                            if (schema.$ref) {
                              return [schema.$ref];
                            }
                          
                          
                          Severity: Minor
                          Found in src/json-schema.js - About 1 hr to fix

                            Function bodyFromSchema has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function bodyFromSchema(schema, payload, parser, contentType = 'application/json') {
                              const dereferencedSchema = dereference(schema, schema);
                              const { Asset } = parser.minim.elements;
                              let asset = null;
                            
                            
                            Severity: Minor
                            Found in src/generator.js - About 1 hr to fix

                              Function generateObject has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                generateObject(schema) {
                                  const {
                                    Object: ObjectElement,
                                  } = this.minim.elements;
                              
                              
                              Severity: Minor
                              Found in src/schema.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language