Showing 314 of 596 total issues
Method get_name_identifiers
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def get_name_identifiers(author)
name_identifiers =
Array.wrap(author.fetch("nameIdentifier", nil)).reduce([]) do |sum, n|
n = { "__content__" => n } if n.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"
Further reading
Method query_aggregations
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.query_aggregations(disable_facets: false)
if !disable_facets
{
# number of resourceTypeGeneral increased from 16 to 28 in schema 4.4
resource_types: { terms: { field: "resource_type_id_and_name", size: 30, min_doc_count: 1 } },
Method wikidata_query
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def wikidata_query(employment)
return [] if employment.blank?
ringgold_filter =
Array.wrap(employment).reduce([]) do |sum, f|
Method register_url
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def register_url
if url.blank?
raise ActionController::BadRequest.new,
"[Handle] Error updating DOI " + doi + ": url missing."
end
Method check_issn
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def check_issn
Array.wrap(issn).each do |i|
if !i.is_a?(Hash)
errors.add(:issn, "ISSN should be an object and not a string.")
elsif i["issnl"].present?
- 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 page_from_params
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def page_from_params(params)
p = params.to_unsafe_h.dig(:page)
page = p.is_a?(Hash) ? p.symbolize_keys : {}
- 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 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def as_indexed_json(options = {})
{
"id" => uid,
"uid" => uid,
"name" => name,
Method get_should_clause
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_should_clause
options = @options
should_query = []
minimum_should_match = 0
if options[:provider_id].present?
Method csv
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def csv
provider = {
name: name,
provider_id: symbol,
consortium_id: consortium.present? ? consortium.symbol : "",
Method import_by_id
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_by_id(options = {})
return nil if options[:id].blank?
id = options[:id].to_i
index =
Method import_doi
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_doi(id, options = {})
doi_id = validate_doi(id)
return nil if doi_id.blank?
# check whether DOI has been stored with DataCite already
Method show
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
# only show findable DataCite DOIs to anonymous users and role user
# use current_user role to determine permissions to access draft and registered dois
# instead of using ability
# response = DataciteDoi.find_by_id(params[:id])
Method export_doi_counts
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.export_doi_counts(query: nil)
# Loop through all clients
page = { size: 1_000, number: 1 }
response = self.query(query, page: page)
clients = response.results.to_a
- 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 parse_xml
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def parse_xml(input, options = {})
return {} if input.blank?
# check whether input is id and we need to fetch the content
id = normalize_id(input, sandbox: sandbox)
- 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 a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "name"
{ "doi" => { order: "asc" } }
- 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 a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "relevance"
{ "_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 import_in_bulk
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_in_bulk(ids, options = {})
index =
if Rails.env.test?
index_name
elsif options[:index].present?
Method convert_affiliation_by_id
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.convert_affiliation_by_id(options = {})
return nil if options[:id].blank?
id = options[:id].to_i
count = 0
Method safe_params
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def safe_params
if params[:data].blank?
fail JSON::ParserError,
"You need to provide a payload following the JSONAPI spec"
end
Method import_by_id
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_by_id(options = {})
return nil if options[:id].blank?
id = options[:id].to_i
index =