app/models/admin_ability.rb
Method signed_in_with_organizer_role
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def signed_in_with_organizer_role(user, conf_ids_for_organization_admin = [])
# ids of all the conferences for which the user has the 'organizer' role and
# conferences that belong to organizations for which user is 'organization_admin'
conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq
# ids of all the tracks that belong to the programs of the above conferences
Method common_abilities_for_roles
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def common_abilities_for_roles(user)
can :manage, Registration, user_id: user.id
can :index, Conference
can :show, Registration, &:new_record?
Method signed_in_with_cfp_role
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def signed_in_with_cfp_role(user)
# ids of all the conferences for which the user has the 'cfp' role
conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)
can :show, Conference do |conf|
Method signed_in_with_track_organizer_role
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def signed_in_with_track_organizer_role(user)
# ids of all the conferences for which the user has the 'track organizer' role
conf_ids_for_track_organizer = Track.with_role(:track_organizer, user).joins(:program).pluck(:conference_id)
# ids of all the tracks for which the user has the 'track_organizer' role
track_ids_for_track_organizer = Track.with_role(:track_organizer, user).pluck(:id)
Method common_abilities_for_roles
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def common_abilities_for_roles(user)
can :manage, Registration, user_id: user.id
can :index, Conference
can :show, Registration, &:new_record?
- 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 signed_in_with_roles
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def signed_in_with_roles(user)
signed_in_with_organization_admin_role(user) if user.has_cached_role? :organization_admin, :any
signed_in_with_organizer_role(user) if user.has_cached_role? :organizer, :any
signed_in_with_cfp_role(user) if user.has_cached_role? :cfp, :any
signed_in_with_info_desk_role(user) if user.has_cached_role? :info_desk, :any
- 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"