Showing 80 of 86 total issues
Class XMLParser
has 51 methods (exceeds 20 allowed). Consider refactoring. Open
class XMLParser
class << self
#
# Parse XML bibdata
#
File xml_parser.rb
has 433 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "nokogiri"
module RelatonBib
class XMLParser
class << self
File hash_converter.rb
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RelatonBib
module HashConverter
extend self
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
File bibliographic_item.rb
has 415 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "relaton_bib/typed_uri"
require "relaton_bib/document_identifier"
require "relaton_bib/copyright_association"
require "relaton_bib/formatted_string"
require "relaton_bib/contribution_info"
Method to_hash
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
hash = {}
hash["schema-version"] = schema unless embedded
hash["id"] = id if id
hash["title"] = title.to_hash if title&.any?
- 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 render_xml
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def render_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
root = opts[:bibdata] ? :bibdata : :bibitem
xml = opts[:builder].send(root) do |builder| # rubocop:disable Metrics/BlockLength
builder.fetched fetched if fetched
title.to_xml(**opts)
- 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 render_address
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def render_address(builder, contrib) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
address, contact = address_contact contrib.entity.contact
if address || contact.any?
builder.address do |xml|
# address = contrib.entity.contact.detect { |cn| cn.is_a? Address }
- 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 initialize
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def initialize(**args)
if args[:type] && !TYPES.include?(args[:type])
Util.warn %{Type `#{args[:type]}` is invalid.}
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
Class BibtexBuilder
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class BibtexBuilder
ATTRS = %i[
type id title author editor booktitle series number edition contributor
date address note relation extent classification keyword docidentifier
timestamp link
Method initialize
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(**args)
if args[:type] && !TYPES.include?(args[:type])
Util.warn %{Type `#{args[:type]}` is invalid.}
end
Method to_xml
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
opts[:builder].name do |builder|
builder.abbreviation { abbreviation.to_xml builder } if abbreviation
if completename
builder.completename { completename.to_xml builder }
- 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 scan_xml
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def scan_xml(parts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
return "" unless parts.any?
out = ""
while parts.any? && (parts.first[3] || parts.first[4])
- 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 to_asciibib
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
pref = prefix.empty? ? prefix : "#{prefix}."
out = prefix.empty? ? "[%bibitem]\n== {blank}\n" : ""
out += "#{pref}id:: #{id}\n" if id
out += "#{pref}fetched:: #{fetched}\n" if fetched
- 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 BibliographicItem
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class BibliographicItem
include RelatonBib
TYPES = %W[article book booklet manual proceedings presentation
thesis techreport standard unpublished map electronic\sresource
Method docids
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
ret = []
si = reference.at("./seriesInfo[@name='Internet-Draft']",
"./front/seriesInfo[@name='Internet-Draft']")
if si
- 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 render_xml
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
root = opts[:bibdata] ? :bibdata : :bibitem
xml = opts[:builder].send(root) do |builder| # rubocop:disable Metrics/BlockLength
builder.fetched fetched if fetched
title.to_xml(**opts)
Method to_xml
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def to_xml(builder) # rubocop:disable Metrics/MethodLength
xml = builder.series do
formattedref&.to_xml builder
builder.title { title.to_xml builder }
builder.place place if place
- 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 to_xml
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def to_xml(builder)
xml = builder.structuredidentifier do |b|
agency&.each { |a| b.agency a }
b.class_ klass if klass
b.docnumber docnumber
- 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 bibxml_parser.rb
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RelatonBib
module BibXMLParser
# SeriesInfo what should be saved as docidentifiers in the Relaton model.
SERIESINFONAMES = ["DOI"].freeze
RFCPREFIXES = %w[RFC BCP FYI STD].freeze
Method to_hash
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
hash = {}
hash["schema-version"] = schema unless embedded
hash["id"] = id if id
hash["title"] = title.to_hash if title&.any?