matteozambon89/trailpack-swagger

View on GitHub

Showing 79 of 79 total issues

Function getDefinitions has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getDefinitions(config, doc) {
    const definitions = {}

    definitions['x-any'] = {
      'properties': {}
Severity: Major
Found in api/services/SwaggerService.js - About 2 hrs to fix

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

        pathItem.get.parameters.push({
          name: 'populate',
          in: 'query',
          description: 'Properties to populate (valid: ' + modelPopulates[modelName].join(', ') + ')',
          required: false,
    Severity: Major
    Found in api/services/SwaggerService.js and 1 other location - About 2 hrs to fix
    api/services/SwaggerService.js on lines 1094..1103

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

    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

        pathItem.get.parameters.push({
          name: 'populate',
          in: 'query',
          description: 'Properties to populate (check populate for ' +
                        inflect.titleize(modelRelation.model) +
    Severity: Major
    Found in api/services/SwaggerService.js and 1 other location - About 2 hrs to fix
    api/services/SwaggerService.js on lines 1286..1297

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

    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

        pathItem.get.parameters.push({
          name: 'populate',
          in: 'query',
          description: 'Properties to populate (valid: ' + modelPopulates[modelName].join(', ') + ')',
          required: false,
    Severity: Major
    Found in api/services/SwaggerService.js and 1 other location - About 2 hrs to fix
    api/services/SwaggerService.js on lines 1197..1206

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

    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

        pathItem.get.parameters.push({
          name: 'populate',
          in: 'query',
          description: 'Properties to populate (check populate for ' +
                        inflect.titleize(modelRelation.model) +
    Severity: Major
    Found in api/services/SwaggerService.js and 1 other location - About 2 hrs to fix
    api/services/SwaggerService.js on lines 1448..1459

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

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

      parseDefinitionModelProperty(property) {
        property.type = property.type.toLowerCase()
    
        if (property.type === 'integer') {
          property.type = 'integer'
    Severity: Minor
    Found in api/services/SwaggerService.js - About 2 hrs to fix

      Function genPropertyExample has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        genPropertyExample (propertyExample, modelExample, withRel) {
          let example = null
      
          if (typeof propertyExample === 'string') {
            const directive = this.extractExampleDirective(propertyExample)
      Severity: Minor
      Found in api/services/SwaggerService.js - About 1 hr to fix

        Function getBasePath has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getBasePath(config) {
            if (config.swagger.basePath) {
              return config.swagger.basePath
            }
            else if (config.footprints && config.footprints.prefix) {
        Severity: Minor
        Found in api/services/SwaggerService.js - About 1 hr to fix

          Function parseDefinitionModelProperty has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            parseDefinitionModelProperty(property) {
              property.type = property.type.toLowerCase()
          
              if (property.type === 'integer') {
                property.type = 'integer'
          Severity: Minor
          Found in api/services/SwaggerService.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

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

              pathItem.get.parameters.push({
                name: 'limit',
                in: 'query',
                description: 'Pagination size',
                required: false,
          Severity: Major
          Found in api/services/SwaggerService.js and 1 other location - About 1 hr to fix
          api/services/SwaggerService.js on lines 1298..1306

          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

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

              pathItem.get.parameters.push({
                name: 'limit',
                in: 'query',
                description: 'Pagination size',
                required: false,
          Severity: Major
          Found in api/services/SwaggerService.js and 1 other location - About 1 hr to fix
          api/services/SwaggerService.js on lines 1104..1112

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

            getModelCriteria(config, doc, modelName, keepId) {
              const definition = doc.definitions[modelName]
          
              const criterias = []
          
          
          Severity: Minor
          Found in api/services/SwaggerService.js - About 1 hr to fix

            Function getPathLocalRegister has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              getPathLocalRegister(paths, config) {
                const pathItem = {}
            
                const localStrategy = config.passport.strategies.local
                let usernameField = 'username'
            Severity: Minor
            Found in api/services/SwaggerService.js - About 1 hr to fix

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

                  pathItem.get.parameters.push({
                    name: 'cid',
                    in: 'path',
                    description: inflect.titleize(modelRelation.property) + ' id',
                    required: true,
              Severity: Major
              Found in api/services/SwaggerService.js and 2 other locations - About 1 hr to fix
              api/services/SwaggerService.js on lines 1483..1489
              api/services/SwaggerService.js on lines 1525..1531

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

              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

                  pathItem.put.parameters.push({
                    name: 'cid',
                    in: 'path',
                    description: inflect.titleize(modelRelation.property) + ' id',
                    required: true,
              Severity: Major
              Found in api/services/SwaggerService.js and 2 other locations - About 1 hr to fix
              api/services/SwaggerService.js on lines 1441..1447
              api/services/SwaggerService.js on lines 1525..1531

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

              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

                  pathItem.delete.parameters.push({
                    name: 'cid',
                    in: 'path',
                    description: inflect.titleize(modelRelation.model) + ' id',
                    required: true,
              Severity: Major
              Found in api/services/SwaggerService.js and 2 other locations - About 1 hr to fix
              api/services/SwaggerService.js on lines 1441..1447
              api/services/SwaggerService.js on lines 1483..1489

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

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

                getModelCriteria(config, doc, modelName, keepId) {
                  const definition = doc.definitions[modelName]
              
                  const criterias = []
              
              
              Severity: Minor
              Found in api/services/SwaggerService.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 getDefinitions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                getDefinitions(config, doc) {
                  const definitions = {}
              
                  definitions['x-any'] = {
                    'properties': {}
              Severity: Minor
              Found in api/services/SwaggerService.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

                  pathItem.get.summary = 'List all ' +
                                          inflect.titleize(inflect.pluralize(modelRelation.property)) +
                                          ' on ' +
                                          inflect.titleize(modelRelation.model)
              Severity: Major
              Found in api/services/SwaggerService.js and 1 other location - About 1 hr to fix
              api/services/SwaggerService.js on lines 1320..1323

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

              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

                  pathItem.post.summary = 'Create a ' +
                                          inflect.titleize(inflect.pluralize(modelRelation.property)) +
                                          ' on ' +
                                          inflect.titleize(modelRelation.model)
              Severity: Major
              Found in api/services/SwaggerService.js and 1 other location - About 1 hr to fix
              api/services/SwaggerService.js on lines 1267..1270

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

              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