sul-dlss/moab-versioning

View on GitHub

Showing 28 of 32 total issues

Class FileGroupDifference has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class FileGroupDifference < Serializer::Serializable
    include HappyMapper

    # The name of the XML element used to serialize this objects data
    tag 'fileGroupDifference'
Severity: Minor
Found in lib/moab/file_group_difference.rb - About 3 hrs to fix

    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

    Class StorageObjectValidator has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class StorageObjectValidator
        METADATA_DIR = 'metadata'
        CONTENT_DIR = 'content'
        EXPECTED_DATA_SUB_DIRS = [CONTENT_DIR, METADATA_DIR].freeze
        IMPLICIT_DIRS = ['.', '..'].freeze # unlike Find.find, Dir.entries returns the current/parent dirs
    Severity: Minor
    Found in lib/moab/storage_object_validator.rb - About 2 hrs to fix

      Class StorageObjectVersion has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class StorageObjectVersion
          # @return [Integer] The ordinal version number
          attr_accessor :version_id
      
          # @return [String] The "v0001" directory name derived from the version id
      Severity: Minor
      Found in lib/moab/storage_object_version.rb - About 2 hrs to fix

        Class FileInventory has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class FileInventory < Serializer::Manifest
            include HappyMapper
        
            # The name of the XML element used to serialize this object's data
            tag 'fileInventory'
        Severity: Minor
        Found in lib/moab/file_inventory.rb - About 2 hrs to fix

          Class StorageObject has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class StorageObject
              # @return [String] The digital object ID (druid)
              attr_accessor :digital_object_id
          
              # @return [Pathname] The location of the object's storage home directory
          Severity: Minor
          Found in lib/moab/storage_object.rb - About 2 hrs to fix

            Method create_tagfile_manifests has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_tagfile_manifests
                  manifest_pathname = {}
                  manifest_file = {}
                  DEFAULT_CHECKSUM_TYPES.each do |type|
                    manifest_pathname[type] = bag_pathname.join("tagmanifest-#{type}.txt")
            Severity: Minor
            Found in lib/moab/bagger.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 find_storage_root has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def find_storage_root(object_id, include_deposit = false)
                  # Search for the object's home directory in the storage areas
                  branch = storage_branch(object_id)
                  storage_roots.each do |root|
                    root_trunk = root.join(storage_trunk)
            Severity: Minor
            Found in lib/moab/storage_repository.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 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 create_payload_manifests has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def create_payload_manifests
                    manifest_pathname = {}
                    manifest_file = {}
                    DEFAULT_CHECKSUM_TYPES.each do |type|
                      manifest_pathname[type] = bag_pathname.join("manifest-#{type}.txt")
              Severity: Minor
              Found in lib/moab/bagger.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 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 verify_version_inventory has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def verify_version_inventory
                    result = VerificationResult.new('version_inventory')
                    version_inventory = file_inventory('version')
                    result.subentities << VerificationResult.verify_value('inventory_key', composite_key, version_inventory.composite_key)
                    signature_catalog = self.signature_catalog
              Severity: Minor
              Found in lib/moab/storage_object_version.rb - About 1 hr to fix

                Method storage_roots has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def storage_roots
                      unless defined?(@storage_roots)
                        raise(MoabRuntimeError, 'Moab::Config.storage_roots not found in config file') if Moab::Config.storage_roots.nil?
                
                        @storage_roots = [Moab::Config.storage_roots].flatten.collect { |filesystem| Pathname(filesystem) }
                Severity: Minor
                Found in lib/moab/storage_repository.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 deep_diff has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.deep_diff(*hashes)
                      diff = {}
                      case hashes.length
                      when 4
                        ltag, left, rtag, right = hashes
                Severity: Minor
                Found in lib/serializer/serializable.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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update(version_inventory, data_pathname)
                      version_inventory.groups.each do |group|
                        group.files.each do |file|
                          unless @signature_hash.key?(file.signature)
                            entry = SignatureCatalogEntry.new
                Severity: Minor
                Found in lib/moab/signature_catalog.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 normalize_group_signatures has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def normalize_group_signatures(group, group_pathname = nil)
                      unless group_pathname.nil?
                        group_pathname = Pathname(group_pathname)
                        raise(MoabRuntimeError, "Could not locate #{group_pathname}") unless group_pathname.exist?
                      end
                Severity: Minor
                Found in lib/moab/signature_catalog.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 differences_detail has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def differences_detail
                      # return self.summary if difference_count == 0
                      inv_diff = to_hash
                      inv_diff['group_differences'].each_value do |group_diff|
                        delete_subsets = []
                Severity: Minor
                Found in lib/moab/file_inventory_difference.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 shell_execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def shell_execute(command)
                      require 'open3'
                      stdout, stderr, status = Open3.capture3(command.chomp)
                      if status.success? && status.exitstatus.zero?
                        stdout
                Severity: Minor
                Found in lib/moab/bagger.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 eql? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def eql?(other)
                      return false if size.to_i != other.size.to_i
                
                      self_checksums = checksums
                      other_checksums = other.checksums
                Severity: Minor
                Found in lib/moab/file_signature.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 verify_version_inventory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def verify_version_inventory
                      result = VerificationResult.new('version_inventory')
                      version_inventory = file_inventory('version')
                      result.subentities << VerificationResult.verify_value('inventory_key', composite_key, version_inventory.composite_key)
                      signature_catalog = self.signature_catalog
                Severity: Minor
                Found in lib/moab/storage_object_version.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

                Severity
                Category
                Status
                Source
                Language