relaton/relaton-bib

View on GitHub
lib/relaton_bib/structured_identifier.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

    def to_hash
      hash = { "docnumber" => docnumber }
      hash["type"] = type if type
      hash["agency"] = single_element_array agency if agency&.any?
      hash["class"] = klass if klass
Severity: Minor
Found in lib/relaton_bib/structured_identifier.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

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

    def to_asciibib(prefix) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
      out = "#{prefix}.docnumber:: #{docnumber}\n"
      agency.each { |a| out += "#{prefix}.agency:: #{a}\n" }
      out += "#{prefix}.type:: #{type}\n" if type
      out += "#{prefix}.class:: #{klass}\n" if klass
Severity: Minor
Found in lib/relaton_bib/structured_identifier.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

There are no issues that match your filters.

Category
Status