relaton/relaton-bib

View on GitHub

Showing 81 of 81 total issues

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

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

    File xml_parser.rb has 430 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

      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
      
      
      Severity: Minor
      Found in lib/relaton_bib/hash_converter.rb - About 6 hrs to fix

        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?
        Severity: Minor
        Found in lib/relaton_bib/bibliographic_item.rb - About 5 hrs 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

        File bibliographic_item.rb has 412 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"
        Severity: Minor
        Found in lib/relaton_bib/bibliographic_item.rb - About 5 hrs to fix

          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)
          Severity: Minor
          Found in lib/relaton_bib/bibliographic_item.rb - About 4 hrs 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 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 }
          Severity: Minor
          Found in lib/relaton_bib/renderer/bibxml.rb - About 4 hrs 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 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 %{WARNING: type `#{args[:type]}` is invalid.}
                end
          
          
          Severity: Minor
          Found in lib/relaton_bib/bibliographic_item.rb - About 4 hrs 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

          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
          Severity: Minor
          Found in lib/relaton_bib/renderer/bibtex_builder.rb - About 3 hrs to fix

            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 %{WARNING: type `#{args[:type]}` is invalid.}
                  end
            
            
            Severity: Major
            Found in lib/relaton_bib/bibliographic_item.rb - About 2 hrs to fix

              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 }
              Severity: Minor
              Found in lib/relaton_bib/full_name.rb - About 2 hrs 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 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])
              Severity: Minor
              Found in lib/relaton_bib/formatted_string.rb - About 2 hrs 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 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
              Severity: Minor
              Found in lib/relaton_bib/bibliographic_item.rb - About 2 hrs 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 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
              Severity: Minor
              Found in lib/relaton_bib/bibxml_parser.rb - About 2 hrs 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

              Class BibliographicItem has 22 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
              Severity: Minor
              Found in lib/relaton_bib/bibliographic_item.rb - About 2 hrs to fix

                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)
                Severity: Major
                Found in lib/relaton_bib/bibliographic_item.rb - About 2 hrs to fix

                  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
                  Severity: Minor
                  Found in lib/relaton_bib/structured_identifier.rb - About 2 hrs 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 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
                  Severity: Minor
                  Found in lib/relaton_bib/series.rb - About 2 hrs 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

                  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
                  Severity: Minor
                  Found in lib/relaton_bib/bibxml_parser.rb - About 2 hrs to fix

                    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?
                    Severity: Minor
                    Found in lib/relaton_bib/bibliographic_item.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language