jaumard/trailpack-acl

View on GitHub

Showing 9 of 22 total issues

Function checkModel has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  checkModel(req, res, next) {
    const modelName = req.params.model || req.params.parentModel
    const user = req.user
    const defaultRole = this.app.config.permissions.defaultRole

Severity: Major
Found in api/policies/CheckPermissions.js - About 3 hrs to fix

    Function checkRoute has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      checkRoute(req, res, next) {
        const user = req.user
        const defaultRole = this.app.config.permissions.defaultRole
    
        const permissionsConfig = _.get(req.route, 'config.app.permissions')
    Severity: Minor
    Found in api/policies/CheckPermissions.js - About 1 hr to fix

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

        static config(app, Sequelize) {
          return {
            options: {
              classMethods: {
                associate: (models) => {
      Severity: Minor
      Found in api/models/Permission.js - About 1 hr to fix

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

          loadFixtures: app => {
            return Promise.all([
              app.services.FootprintService.find('role', {}).then(roles => {
                if (!roles || roles.length === 0) {
                  return lib.Utils.loadRoles(app)
        Severity: Minor
        Found in lib/utils.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

        Avoid deeply nested control flow statements.
        Open

                      if (action === 'update' || action === 'destroy') {
                        return next({
                          message: 'Update and Destroy are not yet supported with permissions, please do your request manually',
                          statusCode: 400,
                          code: 'E_UNSUPPORTED'
        Severity: Major
        Found in api/policies/CheckPermissions.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        if (modelName === 'user') {
                          if (req.params.id === user.id) {
                            return next()
                          }
                          else {
          Severity: Major
          Found in api/policies/CheckPermissions.js - About 45 mins to fix

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

              checkModel(req, res, next) {
                const modelName = req.params.model || req.params.parentModel
                const user = req.user
                const defaultRole = this.app.config.permissions.defaultRole
            
            
            Severity: Minor
            Found in api/policies/CheckPermissions.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 (modelName === 'user') {
                            if (req.params.id === user.id) {
                              return next()
                            }
                            else {
            Severity: Major
            Found in api/policies/CheckPermissions.js - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                          return next()
              Severity: Major
              Found in api/policies/CheckPermissions.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language