relaton/relaton-bib

View on GitHub
lib/relaton_bib/xml_parser.rb

Summary

Maintainability
D
1 day
Test Coverage

Class XMLParser has 51 methods (exceeds 20 allowed). Consider refactoring.
Open

  class XMLParser
    class << self
      #
      # Parse XML bibdata
      #
Severity: Major
Found in lib/relaton_bib/xml_parser.rb - About 7 hrs to fix

    File xml_parser.rb has 433 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "nokogiri"
    
    module RelatonBib
      class XMLParser
        class << self
    Severity: Minor
    Found in lib/relaton_bib/xml_parser.rb - About 6 hrs to fix

      Method item_data has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      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],
      Severity: Minor
      Found in lib/relaton_bib/xml_parser.rb - About 1 hr to fix

        Method fetch_dates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        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,
        Severity: Minor
        Found in lib/relaton_bib/xml_parser.rb - About 25 mins to fix

        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

              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],
        Severity: Minor
        Found in lib/relaton_bib/xml_parser.rb - About 25 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status