Showing 183 of 288 total issues
Method random_image_including_private
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def random_image_including_private(format: :medium)
@random_image_including_private_cache ||= {}
key = self.class.name + self.id.to_s
return @random_image_including_private_cache[key] if @random_image_including_private_cache.key?(key)
- 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 creatable_by?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.creatable_by?(user)
return false unless user.present?
return false if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(user.email)
return true if PermissionService.billing_plan_allows_extended_content?(user: user)
- 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 readable_by?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def readable_by? user
return true if user && user.site_administrator?
return true if ::PermissionService.user_owns_any_containing_universe?(user: user, content: resource)
return true if ::PermissionService.user_owns_content?(user: user, content: resource)
return true if ::PermissionService.content_is_public?(content: resource)
- 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 update
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update
document = Document.with_deleted.find_or_initialize_by(id: params[:id])
unless document.updatable_by?(current_user)
redirect_to(dashboard_path, notice: "You don't have permission to do that!")
- 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 chip_template
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.chip_template(class_model=nil)
content_tag(:span, class: 'chip') do
body = ''
if class_model
body += content_tag(:span, class: class_model ? "#{class_model.text_color}" : '') do
- 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
Avoid too many return
statements within this method. Open
return true if ::PermissionService.user_can_contribute_to_containing_universe?(user: user, content: resource)
Avoid too many return
statements within this method. Open
return false
Avoid too many return
statements within this method. Open
return false
Avoid too many return
statements within this method. Open
return false
Avoid too many return
statements within this method. Open
return redirect_to root_path, notice: "You don't have permission to view that content."
Avoid too many return
statements within this method. Open
return false
Avoid too many return
statements within this method. Open
return true if user.active_promo_codes.any?
Avoid too many return
statements within this method. Open
return true if PermissionService.content_is_in_a_public_universe?(content: resource)
Avoid too many return
statements within this method. Open
return false
Avoid too many return
statements within this method. Open
return true if ::PermissionService.content_is_in_a_public_universe?(content: resource)
Avoid too many return
statements within this method. Open
return true if is_premium_page && PermissionService.user_is_on_premium_plan?(user: user)
Avoid too many return
statements within this method. Open
return true if user && resource.universe.present? && resource.universe.contributors.pluck(:user_id).include?(user.id)
Avoid too many return
statements within this method. Open
return true if user && user.site_administrator?
Avoid too many return
statements within this method. Open
return true if user && resource.universe.present? && resource.universe.user_id == user.id
Avoid too many return
statements within this method. Open
return false