relaton/relaton-bib

View on GitHub
lib/relaton_bib/bibliographic_item.rb

Summary

Maintainability
F
4 days
Test Coverage

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

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

      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

      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
      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_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

            Method to_asciibib has 44 lines of code (exceeds 25 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 1 hr to fix

              There are no issues that match your filters.

              Category
              Status