relaton/relaton-bib

View on GitHub
lib/relaton_bib/renderer/bibxml.rb

Summary

Maintainability
C
1 day
Test Coverage

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 render_bibxml_ref has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def render_bibxml_ref(builder, include_keywords) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
        builder.reference(**ref_attrs) do |xml|
          if @bib.title.any? || @bib.contributor.any? || @bib.date.any? || @bib.abstract.any? ||
              @bib.editorialgroup&.technical_committee&.any? ||
              (include_keywords && @bib.keyword.any?)
Severity: Minor
Found in lib/relaton_bib/renderer/bibxml.rb - About 1 hr 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

Consider simplifying this complex logical expression.
Open

          if @bib.title.any? || @bib.contributor.any? || @bib.date.any? || @bib.abstract.any? ||
              @bib.editorialgroup&.technical_committee&.any? ||
              (include_keywords && @bib.keyword.any?)
            xml.front do
              xml.title @bib.title[0].title.content if @bib.title.any?
Severity: Major
Found in lib/relaton_bib/renderer/bibxml.rb - About 1 hr to fix

    Method render_person has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_person(builder, person) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
            render_organization builder, person.affiliation.first&.organization
            if person.name.completename
              builder.parent[:fullname] = person.name.completename.content
            elsif person.name.forename.any?
    Severity: Minor
    Found in lib/relaton_bib/renderer/bibxml.rb - About 55 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 ref_attrs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def ref_attrs # rubocop:disable Metrics/AbcSize
            discopes = %w[anchor docName number]
            attrs = @bib.docidentifier.each_with_object({}) do |di, h|
              next unless discopes.include?(di.scope)
    
    
    Severity: Minor
    Found in lib/relaton_bib/renderer/bibxml.rb - About 45 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 render_authors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_authors(builder) # rubocop:disable Metrics/AbcSize
            @bib.contributor.each do |c|
              builder.author do |xml|
                xml.parent[:role] = "editor" if c.role.detect { |r| r.type == "editor" }
                if c.entity.is_a?(Person) then render_person xml, c.entity
    Severity: Minor
    Found in lib/relaton_bib/renderer/bibxml.rb - About 35 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 render_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_date(builder) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
            dt = @bib.date.detect { |d| d.type == "published" }
            return unless dt
    
            elm = builder.date
    Severity: Minor
    Found in lib/relaton_bib/renderer/bibxml.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