Showing 30 of 32 total issues
Method authorized?
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
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))
- Read upRead up
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
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))
Avoid too many return
statements within this method. Open
Open
return true if controller == 'oauth/applications' && action.in?(%w(new create show index destroy edit update))
Avoid too many return
statements within this method. Open
Open
return true if controller == 'affiliations' && action.in?(%w(create new))
Avoid too many return
statements within this method. Open
Open
return true if controller == "doorkeeper/authorizations" && action.in?(%w(new create))
Avoid too many return
statements within this method. Open
Open
return true if controller == "devise/confirmations" && action.in?(%w(show))
Avoid too many return
statements within this method. Open
Open
return true if controller == "doorkeeper/applications" && action.in?(%w(new create index show edit update destroy))
Avoid too many return
statements within this method. Open
Open
return true if controller == "home" && action.in?(%w(index))
Avoid too many return
statements within this method. Open
Open
return true if controller == "devise/confirmations" && action.in?(%w(show))
Avoid too many return
statements within this method. Open
Open
return true if controller == "users" && action.in?(%w(index show edit update))
Avoid too many return
statements within this method. Open
Open
return true if controller == 'users/registrations' && action.in?(%w(edit update))
Avoid too many return
statements within this method. Open
Open
return true if controller == 'oauth/applications' && action.in?(%w(new create show index destroy edit update))
Avoid too many return
statements within this method. Open
Open
return true if controller == 'users/sessions' && action.in?(%w(create destroy))
Avoid too many return
statements within this method. Open
Open
return true if controller == "devise/sessions" && action.in?(%w(create destroy))
Avoid too many return
statements within this method. Open
Open
return true if controller == "users/sessions" && action.in?(%w(new create))
Avoid too many return
statements within this method. Open
Open
return true if controller == "home" && action.in?(%w(index))
Avoid too many return
statements within this method. Open
Open
return true if controller == 'doorkeeper/authorized_applications' && action.in?(%w(index destroy))
Avoid too many return
statements within this method. Open
Open
return true if controller == "devise/confirmations" && action.in?(%w(show))
Avoid too many return
statements within this method. Open
Open
return true if controller == "doorkeeper/applications" && action.in?(%w(new create index show edit update destroy))
Avoid too many return
statements within this method. Open
Open
return true if controller == "devise/sessions" && action.in?(%w(new))