Method create
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
def create
unless params[:collection_names]
flash[:error] = ts("What collections did you want to add?")
redirect_to(request.env["HTTP_REFERER"] || root_path) and return
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 create
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
unless params[:collection_names]
flash[:error] = ts("What collections did you want to add?")
redirect_to(request.env["HTTP_REFERER"] || root_path) and return
end
Method update_multiple_with_params
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def update_multiple_with_params(allowed_items:, update_params:, success_path:)
# Collect any failures so that we can display errors:
@collection_items = []
# Make sure that the keys are integers so that we can look up the
- 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 index
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
# TODO: AO3-6507 Refactor to use send instead of case statements.
if @collection && @collection.user_is_maintainer?(current_user)
@collection_items = @collection.collection_items.include_for_works
Method index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def index
# TODO: AO3-6507 Refactor to use send instead of case statements.
if @collection && @collection.user_is_maintainer?(current_user)
@collection_items = @collection.collection_items.include_for_works
- 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"