Method parents
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def parents()
parent_media_set_ids = params[:parent_media_set_ids]
parent_media_sets = MediaSet.accessible_by_user(current_user, :edit).find(parent_media_set_ids)
child_resources = Array(@media_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 parents
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parents()
parent_media_set_ids = params[:parent_media_set_ids]
parent_media_sets = MediaSet.accessible_by_user(current_user, :edit).find(parent_media_set_ids)
child_resources = Array(@media_resource)
Method image
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def image(size = (params[:size] || :large).to_sym)
if size == :maximum and not current_user.authorized? :download, @media_resource
size = :x_large
end
- 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 browse
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def browse
@browsable_meta_terms = []
@media_resource.meta_data.for_meta_terms.each do |meta_datum|
meta_datum.value.each do |meta_term|
count = MediaResource.filter(current_user, {:meta_data => {meta_datum.meta_key.label.to_sym => {:ids => [meta_term.id]}}}).where("media_resources.id != ?", @media_resource.id).count
- 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 destroy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def destroy
begin
ActiveRecord::Base.transaction do
if MediaResource.where(id: params[:id]).empty?
render json: {}, status: 204
- 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"