Showing 82 of 96 total issues
File utils.rb
has 1241 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Bolognese
module Utils
class << self
include Utils
end
Method read_datacite
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
def read_datacite(string: nil, **options)
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
if read_options.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 read_datacite
has 243 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_datacite(string: nil, **options)
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
if read_options.present?
Method insert_related_items
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def insert_related_items(xml)
return xml unless related_items.present?
xml.relatedItems do
related_items.each do |related_item|
- 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 read_crossref
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def read_crossref(string: nil, **options)
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
if string.present?
m = Maremma.from_xml(string).dig("crossref_result", "query_result", "body", "query", "doi_record") || {}
- 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 read_schema_org
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def read_schema_org(string: nil, **options)
if string.present?
errors = jsonlint(string)
return { "errors" => errors } if errors.present?
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 read_crossref
has 154 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_crossref(string: nil, **options)
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
if string.present?
m = Maremma.from_xml(string).dig("crossref_result", "query_result", "body", "query", "doi_record") || {}
Method read_schema_org
has 138 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_schema_org(string: nil, **options)
if string.present?
errors = jsonlint(string)
return { "errors" => errors } if errors.present?
end
Method get_affiliations
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def get_affiliations(affiliations)
Array.wrap(affiliations).map do |a|
affiliation_identifier = nil
if a.is_a?(String)
name = a.squish
- 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 read_citeproc
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def read_citeproc(string: nil, **options)
if string.present?
errors = jsonlint(string)
return { "errors" => errors } if errors.present?
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 read_bibtex
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def read_bibtex(string: nil, **options)
read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
meta = string.present? ? BibTeX.parse(string).first : OpenStruct.new
- 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
Class Metadata
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class Metadata
include Bolognese::MetadataUtils
attr_accessor :string, :from, :sandbox, :meta, :regenerate, :issue, :show_errors
attr_reader :doc, :page_start, :page_end
File datacite_utils.rb
has 346 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Bolognese
module DataciteUtils
def datacite_xml
@datacite_xml ||= Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.resource(root_attributes) do
Method read_codemeta
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def read_codemeta(string: nil, **options)
if string.present?
errors = jsonlint(string)
return { "errors" => errors } if errors.present?
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
File datacite_reader.rb
has 316 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Bolognese
module Readers
module DataciteReader
def get_datacite(id: nil, **options)
return { "string" => nil, "state" => "not_found" } unless id.present?
Method initialize
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(options={})
options.symbolize_keys!
id = normalize_id(options[:input], options)
ra = nil
File crossref_reader.rb
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Bolognese
module Readers
module CrossrefReader
# CrossRef types from https://api.crossref.org/types
def get_crossref(id: nil, **options)
Method crossref_people
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def crossref_people(bibliographic_metadata, contributor_role)
person = bibliographic_metadata.dig("contributors", "person_name") || bibliographic_metadata.dig("person_name")
organization = Array.wrap(bibliographic_metadata.dig("contributors", "organization"))
person = [{ "name" => ":(unav)", "contributor_role"=>"author" }] if contributor_role == "author" && Array.wrap(person).select { |a| a["contributor_role"] == "author" }.blank? && Array.wrap(organization).select { |a| a["contributor_role"] == "author" }.blank?
- 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 read_citeproc
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_citeproc(string: nil, **options)
if string.present?
errors = jsonlint(string)
return { "errors" => errors } if errors.present?
end
Method insert_descriptions
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def insert_descriptions(xml)
return xml unless descriptions.present? || container && container["title"].present?
xml.descriptions do
if container && container["title"].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"