apiaryio/fury-adapter-swagger

View on GitHub

Showing 64 of 64 total issues

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 (parameter.description) {
      member.description = parameter.description;

      if (this.generateSourceMap) {
        this.createSourceMap(member.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 1440..1446

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

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

            Function ast has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              get ast() {
                if (this.internalAST !== undefined) {
                  return this.internalAST;
                }
            
            
            Severity: Minor
            Found in src/parser.js - 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

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

            export function isJsonContentType(contentType) {
              try {
                const type = parse(contentType);
                return type.suffix === 'json' || type.subtype === 'json';
              } catch (e) {
            Severity: Major
            Found in src/media-type.js and 2 other locations - About 1 hr to fix
            src/media-type.js on lines 37..44
            src/media-type.js on lines 46..53

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

            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

            export function isMultiPartFormData(contentType) {
              try {
                const type = parse(contentType);
                return type.type === 'multipart' && type.subtype === 'form-data';
              } catch (e) {
            Severity: Major
            Found in src/media-type.js and 2 other locations - About 1 hr to fix
            src/media-type.js on lines 20..27
            src/media-type.js on lines 46..53

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

            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

            export function isFormURLEncoded(contentType) {
              try {
                const type = parse(contentType);
                return type.type === 'application' && type.subtype === 'x-www-form-urlencoded';
              } catch (e) {
            Severity: Major
            Found in src/media-type.js and 2 other locations - About 1 hr to fix
            src/media-type.js on lines 20..27
            src/media-type.js on lines 37..44

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

            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 handleSwaggerInfo has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              handleSwaggerInfo() {
                const { Copy } = this.minim.elements;
            
                if (this.swagger.info) {
                  this.withPath('info', () => {
            Severity: Minor
            Found in src/parser.js - About 1 hr to fix

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

                if (schema.patternProperties) {
                  Object.keys(schema.patternProperties).forEach((key) => {
                    references = references.concat(findReferences(schema.patternProperties[key]));
                  });
                }
              Severity: Major
              Found in src/json-schema.js and 1 other location - About 1 hr to fix
              src/json-schema.js on lines 270..274

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

              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 dereference has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              export function dereference(example, root, paths, path) {
                if (example === null || example === undefined) {
                  return example;
                }
              
              
              Severity: Minor
              Found in src/json-schema.js - 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 convertValueToElement has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                convertValueToElement(value, schema) {
                  const validator = new ZSchema();
                  let element;
              
                  if (schema.type === 'file') {
              Severity: Minor
              Found in src/parser.js - 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 convertSchema has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              export function convertSchema(schema, root, swagger, copyDefinitions = true) {
                let references = [];
                const result = convertSubSchema(schema, references, swagger);
              
                if (copyDefinitions) {
              Severity: Minor
              Found in src/json-schema.js - 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

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

                if (schema.properties) {
                  Object.keys(schema.properties).forEach((key) => {
                    actualSchema.properties[key] = recurseConvertSubSchema(schema.properties[key]);
                  });
                }
              Severity: Major
              Found in src/json-schema.js and 1 other location - About 1 hr to fix
              src/json-schema.js on lines 196..201

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

              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 (schema.patternProperties) {
                  Object.keys(schema.patternProperties).forEach((key) => {
                    actualSchema.patternProperties[key] =
                      recurseConvertSubSchema(schema.patternProperties[key]);
                  });
              Severity: Major
              Found in src/json-schema.js and 1 other location - About 1 hr to fix
              src/json-schema.js on lines 190..194

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

              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 (schema.properties) {
                  Object.keys(schema.properties).forEach((key) => {
                    references = references.concat(findReferences(schema.properties[key]));
                  });
                }
              Severity: Major
              Found in src/json-schema.js and 1 other location - About 1 hr to fix
              src/json-schema.js on lines 276..280

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

              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 ast has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                get ast() {
                  if (this.internalAST !== undefined) {
                    return this.internalAST;
                  }
              
              
              Severity: Minor
              Found in src/parser.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language