lib/relaton_bib/xml_parser.rb
Class XMLParser
has 51 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class XMLParser
class << self
#
# Parse XML bibdata
#
File xml_parser.rb
has 433 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require "nokogiri"
module RelatonBib
class XMLParser
class << self
Method item_data
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def item_data(bibitem) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
ext = bibitem.at "//ext"
{
id: bibitem[:id].nil? || bibitem[:id].empty? ? nil : bibitem[:id],
type: bibitem[:type].nil? || bibitem[:type].empty? ? nil : bibitem[:type],
Method fetch_dates
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
item.xpath("./date").each_with_object([]) do |d, a|
type = d[:type].to_s.empty? ? "published" : d[:type]
if (on = d.at("on"))
a << RelatonBib::BibliographicDate.new(type: type, on: on.text,
- 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 item_data
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def item_data(bibitem) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
ext = bibitem.at "//ext"
{
id: bibitem[:id].nil? || bibitem[:id].empty? ? nil : bibitem[:id],
type: bibitem[:type].nil? || bibitem[:type].empty? ? nil : bibitem[:type],
- 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"