matteozambon89/trailpack-swagger

View on GitHub

Showing 28 of 79 total issues

File SwaggerService.js has 1298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @Author: Matteo Zambon <Matteo>
 * @Date:   2017-04-13 06:55:18
 * @Last modified by:   Matteo
 * @Last modified time: 2017-07-30 01:06:47
Severity: Major
Found in api/services/SwaggerService.js - About 3 days to fix

    Function getPathModelByIdAndRelation has 146 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getPathModelByIdAndRelation(paths, config, doc, modelName, modelRelation) {
        const pathItem = {}
        const pathId = standardBasePath +
                        '/' +
                        modelName.toLowerCase() +
    Severity: Major
    Found in api/services/SwaggerService.js - About 5 hrs to fix

      Function getBasePath has a Cognitive Complexity of 38 (exceeds 5 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 5 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

      exports has 40 functions (exceeds 20 allowed). Consider refactoring.
      Open

      module.exports = class SwaggerService extends Service {
      
      // Example
      
        extractExampleDirective (propertyExample) {
      Severity: Minor
      Found in api/services/SwaggerService.js - About 5 hrs to fix

        Function getPathModelByIdAndRelationById has 120 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getPathModelByIdAndRelationById(paths, config, doc, modelName, modelRelation) {
            const pathItem = {}
            const pathId = standardBasePath +
                            '/' +
                            modelName.toLowerCase() +
        Severity: Major
        Found in api/services/SwaggerService.js - About 4 hrs to fix

          Function genPropertyExample has a Cognitive Complexity of 27 (exceeds 5 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 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 getResponses has 90 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getResponses(config, doc) {
              const responses = {}
          
              responses['x-GenericSuccess'] = {
                description: 'Generic Successful Response',
          Severity: Major
          Found in api/services/SwaggerService.js - About 3 hrs to fix

            Function getPathModel has 88 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              getPathModel(paths, config, doc, modelName) {
                const pathItem = {}
                const pathId = standardBasePath + '/' + modelName.toLowerCase()
            
                pathItem.get = {}
            Severity: Major
            Found in api/services/SwaggerService.js - About 3 hrs to fix

              Function getDefinitionModel has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                getDefinitionModel(config, doc, models, modelName) {
                  modelRelations[modelName] = []
                  modelPopulates[modelName] = []
              
                  // Get Models
              Severity: Major
              Found in api/services/SwaggerService.js - About 3 hrs to fix

                Function getPathModelById has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  getPathModelById(paths, config, doc, modelName) {
                    const pathItem = {}
                    const pathId = standardBasePath + '/' + modelName.toLowerCase() + '/{id}'
                
                    pathItem.get = {}
                Severity: Major
                Found in api/services/SwaggerService.js - About 2 hrs to fix

                  Function getDefinitionModel has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                    getDefinitionModel(config, doc, models, modelName) {
                      modelRelations[modelName] = []
                      modelPopulates[modelName] = []
                  
                      // Get Models
                  Severity: Minor
                  Found in api/services/SwaggerService.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 genResponseObject has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    genResponseObject(httpCode, responseName, description) {
                      const responseObject = {}
                  
                      switch (httpCode) {
                      case '200':
                  Severity: Major
                  Found in api/services/SwaggerService.js - About 2 hrs to fix

                    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

                      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

                            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

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language