Showing 314 of 596 total issues
Avoid deeply nested control flow statements. Open
if options[:year].present?
filter <<
{
range: {
created_at: {
Method find_by_ids
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.find_by_ids(ids, options = {})
ids = ids.split(",") if ids.is_a?(String)
options[:page] ||= {}
options[:page][:number] ||= 1
- 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 send_message
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def send_message(body, options = {})
sqs = Aws::SQS::Client.new
queue_name_prefix =
if Rails.env.stage?
ENV["ES_PREFIX"].present? ? "stage" : "test"
- 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 deeply nested control flow statements. Open
query.present? ? [{ prefix: { prefix: query } }] : [{ match_all: {} }]
Method set_minted
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.set_minted
response = Doi.query("+aasm_state:draft +url:*", page: { size: 1, cursor: [] })
message = "#{response.results.total} draft DOIs with URL found in the database."
if response.results.total > 0
- 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 deeply nested control flow statements. Open
if options[:state].present?
filter << { terms: { state: options[:state].to_s.split(",") } }
end
Avoid deeply nested control flow statements. Open
if options[:provider_id].present?
options[:provider_id].split(",").each { |id|
should << { term: { "provider_ids": { value: id, case_insensitive: true } } }
}
minimum_should_match = 1
Method to_jsonapi
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def to_jsonapi
response =
DataciteDoi.query(
nil,
client_id: uid, state: "findable,registered", page: { size: 0, number: 1 }, totals_agg: "client_export",
- 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 convert_publisher_by_id
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.convert_publisher_by_id(options = {})
return nil if options[:id].blank?
id = options[:id].to_i
count = 0
- 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 as_indexed_json
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def as_indexed_json(options = {})
{
"id" => uid,
"uid" => uid,
"provider_id" => provider_id,
- 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 import_by_client
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.import_by_client(client_id, options = {})
# Get optional parameters
import_index =
if Rails.env.test?
index_name
- 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_registrant
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.update_registrant(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || [])
# ra = options[:ra] || "crossref"
source_id = options[:source_id] || "datacite-crossref,crossref"
- 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_datacite_orcid_auto_update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.update_datacite_orcid_auto_update(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || []).to_i
response =
- 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_datacite_ra
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.update_datacite_ra(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || [])
ra = options[:ra] || "crossref"
source_id = "datacite-#{ra}"
- 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 deeply nested control flow statements. Open
pub_obj[0] ? pub_obj[0]["name"] : nil,
Avoid deeply nested control flow statements. Open
pub_obj[1] ? pub_obj[1]["name"] : nil
Avoid deeply nested control flow statements. Open
pub[0] ? { "name": pub[0] } : nil,
Avoid deeply nested control flow statements. Open
pub[1] ? { "name": pub[1] } : nil
Consider simplifying this complex logical expression. Open
unless Array.wrap(doi.creators).all? { |c| c.is_a?(Hash) && c["affiliation"].is_a?(Array) && c["affiliation"].all? { |a| a.is_a?(Hash) } } && Array.wrap(doi.contributors).all? { |c| c.is_a?(Hash) && c["affiliation"].is_a?(Array) && c["affiliation"].all? { |a| a.is_a?(Hash) } }
Rails.logger.error "[MySQL] Error converting affiliations for doi #{doi.doi}: creators #{doi.creators.inspect} contributors #{doi.contributors.inspect}."
fail TypeError, "Affiliation for doi #{doi.doi} is of wrong type" if Rails.env.test?
end
Method set_handle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.set_handle
response = Doi.query("-registered:* +url:* -aasm_state:draft -provider_id:europ -agency:crossref", page: { size: 1, cursor: [] })
message = "#{response.results.total} DOIs found that are not registered in the Handle system."
if response.results.total > 0
- 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"