Showing 45 of 65 total issues
Avoid too many return
statements within this method. Open
return OpenStruct.new(body: { "errors" => [{ "title" => "Missing data" }] }) if work.data.nil?
Method load_index
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def load_index
authorize! :manage, Phrase
sort = case params[:sort]
when "relevance" then { "_score" => { order: "desc" } }
- 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 empty_cookie
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def empty_cookie
value = '{"authenticated":{}}'
domain = if Rails.env.production?
".datacite.org"
- 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 encode_cookie
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def encode_cookie(jwt)
expires_in = 30 * 24 * 3600
expires_at = Time.now.to_i + expires_in
value = '{"authenticated":{"authenticator":"authenticator:oauth2","access_token":"' + jwt + '","expires_in":' + expires_in.to_s + ',"expires_at":' + expires_at.to_s + "}}"
- 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 format_error_message
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def format_error_message(messages)
Array.wrap(messages) do |msg|
if msg["title"].is_a?(Hash) && msg.dig("title", "developer-message").present?
title = msg.dig("title", "developer-message")
elsif msg["title"].is_a?(String)
- 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"