holidayextras/jsonapi-server

View on GitHub

Showing 54 of 94 total issues

Function _getPathOperationObject has 136 lines of code (exceeds 25 allowed). Consider refactoring.
Open

swaggerPaths._getPathOperationObject = options => {
  const pathDefinition = {
    tags: [ options.resourceName ],
    description: options.description,
    parameters: [ ],
Severity: Major
Found in lib/swagger/paths.js - About 5 hrs to fix

    Function _getResourceDefinition has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    swaggerPaths._getResourceDefinition = resourceConfig => {
      if (Object.keys(resourceConfig.handlers || { }).length === 0) return undefined
    
      const resourceDefinition = {
        description: resourceConfig.description,
    Severity: Minor
    Found in lib/swagger/resources.js - About 4 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 _arrayToTree has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    includePP._arrayToTree = (request, includes, filters, callback) => {
      const validationErrors = [ ]
      const tree = {
        _dataItems: null,
        _resourceConfig: [ ].concat(request.resourceConfig)
    Severity: Minor
    Found in lib/postProcessing/include.js - About 4 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 _getResourceDefinition has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    swaggerPaths._getResourceDefinition = resourceConfig => {
      if (Object.keys(resourceConfig.handlers || { }).length === 0) return undefined
    
      const resourceDefinition = {
        description: resourceConfig.description,
    Severity: Major
    Found in lib/swagger/resources.js - About 4 hrs to fix

      Function _getPathOperationObject has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      swaggerPaths._getPathOperationObject = options => {
        const pathDefinition = {
          tags: [ options.resourceName ],
          description: options.description,
          parameters: [ ],
      Severity: Minor
      Found in lib/swagger/paths.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

      File paths.js has 308 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict'
      const swaggerPaths = module.exports = { }
      const jsonApi = require('../../')
      const _ = {
        uniq: require('lodash.uniq')
      Severity: Minor
      Found in lib/swagger/paths.js - About 3 hrs to fix

        Function register has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        removeRelationRoute.register = () => {
          router.bindRoute({
            verb: 'delete',
            path: ':type/:id/relationships/:relation'
          }, (request, resourceConfig, res) => {
        Severity: Major
        Found in lib/routes/removeRelation.js - About 3 hrs to fix

          Function _getSwaggerBase has 80 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          swagger._getSwaggerBase = () => {
            const swaggerConfig = jsonApi._apiConfig.swagger || { }
            let basePath, host, protocol
            if (jsonApi._apiConfig.urlPrefixAlias) {
              const urlObj = url.parse(jsonApi._apiConfig.urlPrefixAlias)
          Severity: Major
          Found in lib/swagger/index.js - About 3 hrs to fix

            Function _fillIncludeTree has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            includePP._fillIncludeTree = (includeTree, request, callback) => {
              /** **
              includeTree = {
                _dataItems: [ ],
                _filter: { },
            Severity: Major
            Found in lib/postProcessing/include.js - About 3 hrs to fix

              Function register has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              foreignKeySearchRoute.register = () => {
                router.bindRoute({
                  verb: 'get',
                  path: ':type/relationships/?'
                }, (request, resourceConfig, res) => {
              Severity: Major
              Found in lib/routes/_foreignKeySearch.js - About 2 hrs to fix

                Function register has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                createRoute.register = () => {
                  router.bindRoute({
                    verb: 'post',
                    path: ':type'
                  }, (request, resourceConfig, res) => {
                Severity: Major
                Found in lib/routes/create.js - About 2 hrs to fix

                  Function register has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  relatedRoute.register = () => {
                    router.bindRoute({
                      verb: 'get',
                      path: ':type/:id/:relation'
                    }, (request, resourceConfig, res) => {
                  Severity: Major
                  Found in lib/routes/related.js - About 2 hrs to fix

                    Function _arrayToTree has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    includePP._arrayToTree = (request, includes, filters, callback) => {
                      const validationErrors = [ ]
                      const tree = {
                        _dataItems: null,
                        _resourceConfig: [ ].concat(request.resourceConfig)
                    Severity: Major
                    Found in lib/postProcessing/include.js - About 2 hrs to fix

                      Function _addDeepPaths has 54 lines of code (exceeds 25 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: Major
                      Found in lib/swagger/paths.js - About 2 hrs to fix

                        Function register has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        updateRoute.register = () => {
                          router.bindRoute({
                            verb: 'patch',
                            path: ':type/:id'
                          }, (request, resourceConfig, res) => {
                        Severity: Major
                        Found in lib/routes/update.js - About 2 hrs to fix

                          Function register has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          addRelationRoute.register = () => {
                            router.bindRoute({
                              verb: 'post',
                              path: ':type/:id/relationships/:relation'
                            }, (request, resourceConfig, res) => {
                          Severity: Major
                          Found in lib/routes/addRelation.js - About 2 hrs to fix

                            Function _generateLink has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            responseHelper._generateLink = (item, schemaProperty, linkProperty) => {
                              const link = {
                                meta: {
                                  relation: 'primary',
                                  // type: schemaProperty._settings.__many || schemaProperty._settings.__one,
                            Severity: Major
                            Found in lib/responseHelper.js - About 2 hrs to fix

                              Function register has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              updateRelationRoute.register = () => {
                                router.bindRoute({
                                  verb: 'patch',
                                  path: ':type/:id/relationships/:relation'
                                }, (request, resourceConfig, res) => {
                              Severity: Minor
                              Found in lib/routes/updateRelation.js - About 2 hrs to fix

                                Function register has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                relationshipsRoute.register = () => {
                                  router.bindRoute({
                                    verb: 'get',
                                    path: ':type/:id/relationships/:relation'
                                  }, (request, resourceConfig, res) => {
                                Severity: Minor
                                Found in lib/routes/relationships.js - About 2 hrs to fix

                                  Function _filterKeepObject has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  filter._filterKeepObject = (someObject, filters) => {
                                    for (const filterName in filters) {
                                      const whitelist = filters[filterName]
                                  
                                      if (someObject.attributes.hasOwnProperty(filterName) || (filterName === 'id')) {
                                  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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language