matteozambon89/trailpack-swagger

View on GitHub

Showing 28 of 79 total issues

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

Function getPathLocalLogin has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

      extractExampleDirective (propertyExample) {
        const directive = {}
    
        // Clean Example
        let propertyExampleClean = propertyExample.replace(/^{{|}}$/g, '')
    Severity: Minor
    Found in api/services/SwaggerService.js - About 1 hr to fix

      Function getPaths has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        getPaths(config, doc) {
          let paths = {}
      
          if (config.passport && config.passport.strategies) {
            for (const authType in config.passport.strategies) {
      Severity: Minor
      Found in api/services/SwaggerService.js - About 55 mins 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 extractExampleDirective has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        extractExampleDirective (propertyExample) {
          const directive = {}
      
          // Clean Example
          let propertyExampleClean = propertyExample.replace(/^{{|}}$/g, '')
      Severity: Minor
      Found in api/services/SwaggerService.js - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

                  if (path1[p] === path2[p]) {
                    basePath.push(path1[p])
                  }
                  else {
                    break
      Severity: Major
      Found in api/services/SwaggerService.js - About 45 mins to fix

        Function getResponses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          getResponses(config, doc) {
            const responses = {}
        
            responses['x-GenericSuccess'] = {
              description: 'Generic Successful Response',
        Severity: Minor
        Found in api/services/SwaggerService.js - About 35 mins 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          genResponseObject(httpCode, responseName, description) {
            const responseObject = {}
        
            switch (httpCode) {
            case '200':
        Severity: Minor
        Found in api/services/SwaggerService.js - About 25 mins 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