holidayextras/jsonapi-server

View on GitHub

Showing 54 of 94 total issues

Function action has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

filter.action = (request, response, callback) => {
  const filters = request.processedFilter
  if (!filters) return callback()

  if (Array.isArray(response.data)) {
Severity: Minor
Found in lib/postProcessing/filter.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 _generateDataItem has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

responseHelper._generateDataItem = (item, schema) => {
  const isSpecialProperty = value => {
    if (!(value instanceof Object)) return false
    if (value._settings) return true
    return false
Severity: Minor
Found in lib/responseHelper.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 simpleAttribute has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

joiConverter.simpleAttribute = joiScheme => {
  let type = joiScheme._type
  if (type === 'any') {
    // { _valids: { _set: [ 'M', 'F' ] } }
    type = typeof (joiScheme._valids._set || [ ])[0]
Severity: Minor
Found in lib/graphQl/joiConverter.js - About 1 hr to fix

    Function action has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    sort.action = (request, response, callback) => {
      let attribute = request.params.sort
      let ascending = 1
      if (!attribute) return callback()
      attribute = (`${attribute}`)
    Severity: Minor
    Found in lib/postProcessing/sort.js - About 1 hr to fix

      Function lowerAction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        ChainHandler.prototype[lowerAction] = function (request) {
          const self = this
          const argsIn = Array.prototype.slice.call(arguments)
          const callback = argsIn.pop()
          // This block catches invocations to synchronous functions (.initialise())
      Severity: Minor
      Found in lib/ChainHandler.js - About 1 hr to fix

        Function _parseFilterElementHelper has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        filter._parseFilterElementHelper = (attributeConfig, filterElement) => {
          if (!filterElement) return { error: 'invalid or empty filter element' }
        
          const parsedElements = [].concat(filterElement).map(scalarElement => filter._parseScalarFilterElement(attributeConfig, scalarElement))
        
        
        Severity: Minor
        Found in lib/filter.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

        Function action has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        sort.action = (request, response, callback) => {
          let attribute = request.params.sort
          let ascending = 1
          if (!attribute) return callback()
          attribute = (`${attribute}`)
        Severity: Minor
        Found in lib/postProcessing/sort.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

        Function _addDeepPaths has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        swaggerPaths._addDeepPaths = (paths, resourceName, resourceConfig, relationName, relation) => {
          const relationType = resourceConfig.attributes[relationName]._settings.__many ? 'many' : 'one'
        
          if (resourceConfig.handlers.find) {
            paths[`/${resourceName}/{id}/${relationName}`] = {
        Severity: Minor
        Found in lib/swagger/paths.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 too many return statements within this function.
        Open

          return null
        Severity: Major
        Found in lib/filter.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return { error: validateResult.error.message }
          Severity: Major
          Found in lib/filter.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return { result: validatedElement }
            Severity: Major
            Found in lib/filter.js - About 30 mins to fix

              Function swap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              joiConverter.swap = (joiScheme, graphQlResources) => {
                let type
                if (!joiScheme._settings) {
                  type = joiConverter.simpleAttribute(joiScheme)
                } else {
              Severity: Minor
              Found in lib/graphQl/joiConverter.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

              Function route has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              rerouter.route = (newRequest, callback) => {
                const validRoutes = router._routes[newRequest.method.toLowerCase()]
              
                const path = rerouter._generateSanePath(newRequest)
                const route = rerouter._pickFirstMatchingRoute(validRoutes, path)
              Severity: Minor
              Found in lib/rerouter.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

              Function _mergeParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              rerouter._mergeParams = (objA, objB) => {
                if (!objB) return objA
                Object.keys(objA).forEach(someKey => {
                  if (!objB[someKey]) {
                    objB[someKey] = objA[someKey]
              Severity: Minor
              Found in lib/rerouter.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