calaway/census

View on GitHub

Showing 30 of 32 total issues

Method authorized? has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

  def authorized?(user, controller, action)
    if user && user.admin?
      return true if controller == 'admin/users' && action.in?(%w(update))
      return true if controller == "invitations" && action.in?(%w(new create update destroy index))
      return true if controller == "admin/dashboard" && action.in?(%w(show))
Severity: Minor
Found in app/services/permission.rb - About 1 day 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

Method authorized? has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def authorized?(user, controller, action)
    if user && user.admin?
      return true if controller == 'admin/users' && action.in?(%w(update))
      return true if controller == "invitations" && action.in?(%w(new create update destroy index))
      return true if controller == "admin/dashboard" && action.in?(%w(show))
Severity: Minor
Found in app/services/permission.rb - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

          return true if controller == 'oauth/applications' && action.in?(%w(new create show index destroy edit update))
    Severity: Major
    Found in app/services/permission.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return true if controller == 'affiliations' && action.in?(%w(create new))
      Severity: Major
      Found in app/services/permission.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return true if controller == "doorkeeper/authorizations" && action.in?(%w(new create))
        Severity: Major
        Found in app/services/permission.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return true if controller == "devise/confirmations" && action.in?(%w(show))
          Severity: Major
          Found in app/services/permission.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return true if controller == "doorkeeper/applications" && action.in?(%w(new create index show edit update destroy))
            Severity: Major
            Found in app/services/permission.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return true if controller == "home" && action.in?(%w(index))
              Severity: Major
              Found in app/services/permission.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return true if controller == "devise/confirmations" && action.in?(%w(show))
                Severity: Major
                Found in app/services/permission.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return true if controller == "users" && action.in?(%w(index show edit update))
                  Severity: Major
                  Found in app/services/permission.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return true if controller == 'users/registrations' && action.in?(%w(edit update))
                    Severity: Major
                    Found in app/services/permission.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return true if controller == 'oauth/applications' && action.in?(%w(new create show index destroy edit update))
                      Severity: Major
                      Found in app/services/permission.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              return true if controller == 'users/sessions' && action.in?(%w(create destroy))
                        Severity: Major
                        Found in app/services/permission.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                return true if controller == "devise/sessions" && action.in?(%w(create destroy))
                          Severity: Major
                          Found in app/services/permission.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                  return true if controller == "users/sessions" && action.in?(%w(new create))
                            Severity: Major
                            Found in app/services/permission.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                    return true if controller == "home" && action.in?(%w(index))
                              Severity: Major
                              Found in app/services/permission.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                      return true if controller == 'doorkeeper/authorized_applications' && action.in?(%w(index destroy))
                                Severity: Major
                                Found in app/services/permission.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                        return true if controller == "devise/confirmations" && action.in?(%w(show))
                                  Severity: Major
                                  Found in app/services/permission.rb - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                          return true if controller == "doorkeeper/applications" && action.in?(%w(new create index show edit update destroy))
                                    Severity: Major
                                    Found in app/services/permission.rb - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                            return true if controller == "devise/sessions" && action.in?(%w(new))
                                      Severity: Major
                                      Found in app/services/permission.rb - About 30 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language