sul-dlss/moab-versioning

View on GitHub
lib/stanford/content_inventory.rb

Summary

Maintainability
B
6 hrs
Test Coverage
A
99%

Method generate_content_metadata has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_content_metadata(file_group, object_id, version_id)
      cm = Nokogiri::XML::Builder.new do |xml|
        xml.contentMetadata(type: 'sample', objectId: object_id) do
          xml.resource(type: 'version', sequence: '1', id: "version-#{version_id}") do
            file_group.files.each do |file_manifestation|
Severity: Minor
Found in lib/stanford/content_inventory.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 validate_content_metadata_details has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def validate_content_metadata_details(content_metadata)
      result = []
      content_metadata_doc =
        case content_metadata.class.name
        when 'String'
Severity: Minor
Found in lib/stanford/content_inventory.rb - About 1 hr to fix

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

        def validate_content_metadata_details(content_metadata)
          result = []
          content_metadata_doc =
            case content_metadata.class.name
            when 'String'
    Severity: Minor
    Found in lib/stanford/content_inventory.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 remediate_checksum_nodes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def remediate_checksum_nodes(file_node, signature)
          # collect <checksum> elements for checksum types that are already present
          checksum_nodes = {}
          file_node.xpath('checksum').each do |checksum_node|
            type = @type_for_name[checksum_node['type']]
    Severity: Minor
    Found in lib/stanford/content_inventory.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

    There are no issues that match your filters.

    Category
    Status