relaton/relaton-bib

View on GitHub
lib/relaton_bib/contributor.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

    def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
      pref = prefix.empty? ? "address" : "#{prefix}.address"
      if formatted_address
        "#{pref}.formatted_address:: #{formatted_address}\n"
      else
Severity: Minor
Found in lib/relaton_bib/contributor.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_xml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def to_xml(doc) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
      doc.address do
        if formatted_address
          doc.formattedAddress formatted_address
        else
Severity: Minor
Found in lib/relaton_bib/contributor.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(**args) # rubocop:disable Metrics/CyclomaticComplexity
      unless args[:formatted_address] || (args[:city] && args[:country])
        raise ArgumentError, "Either formatted address or city and country must be provided"
      end

Severity: Minor
Found in lib/relaton_bib/contributor.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 to_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def to_hash # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
      hash = { "address" => {} }
      if formatted_address
        hash["address"]["formatted_address"] = formatted_address
      else
Severity: Minor
Found in lib/relaton_bib/contributor.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 to_asciibib has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize
      pref = prefix.empty? ? prefix : "#{prefix}."
      out = count > 1 ? "#{pref}affiliation::\n" : ""
      out += name.to_asciibib "#{pref}affiliation.name" if name
      description.each do |d|
Severity: Minor
Found in lib/relaton_bib/contributor.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