apiaryio/fury-adapter-swagger

View on GitHub

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

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

          if (oauth.authorizationUrl) {
            const transition = new Transition();
      
            transition.relation = 'authorize';
            transition.href = oauth.authorizationUrl;
      Severity: Major
      Found in src/parser.js and 1 other location - About 5 hrs to fix
      src/parser.js on lines 530..542

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

      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

          if (oauth.tokenUrl) {
            const transition = new Transition();
      
            transition.relation = 'token';
            transition.href = oauth.tokenUrl;
      Severity: Major
      Found in src/parser.js and 1 other location - About 5 hrs to fix
      src/parser.js on lines 516..528

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

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

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

                            if (parameter.description) {
                              element.description = parameter.description;
                      
                              if (this.generateSourceMap) {
                                this.createSourceMap(element.meta.get('description'), this.path.concat(['description']));
                      Severity: Major
                      Found in src/parser.js and 2 other locations - About 2 hrs to fix
                      src/parser.js on lines 597..603
                      src/parser.js on lines 1467..1473

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

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

                                if (item.description) {
                                  element.description = item.description;
                      
                                  if (this.generateSourceMap) {
                                    this.createSourceMap(element.meta.get('description'), this.path.concat(['description']));
                      Severity: Major
                      Found in src/parser.js and 2 other locations - About 2 hrs to fix
                      src/parser.js on lines 1440..1446
                      src/parser.js on lines 1467..1473

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

                      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

                        if (options.description) {
                          link.description = options.description;
                      
                          if (parser.generateSourceMap) {
                            parser.createSourceMap(link.meta.get('description'), opts.path.concat(['description']));
                      Severity: Major
                      Found in src/link.js and 1 other location - About 2 hrs to fix
                      src/headers.js on lines 80..86

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

                      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