archivesspace/archivesspace

View on GitHub

Showing 1,475 of 2,432 total issues

Method serialize_indexes has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def serialize_indexes(data, xml, fragments)
    data.indexes.each do |note|
      next if note["publish"] === false && !@include_unpublished
      audatt = note["publish"] === false ? {:audience => 'internal'} : {}
      content = ASpaceExport::Utils.extract_note_text(note, @include_unpublished)
Severity: Minor
Found in backend/app/exporters/serializers/ead.rb - About 5 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 serialize_indexes has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def serialize_indexes(data, xml, fragments)
    data.indexes.each do |note|
      next if note["publish"] === false && !@include_unpublished
      content = ASpaceExport::Utils.extract_note_text(note, @include_unpublished)
      head_text = nil
Severity: Minor
Found in backend/app/exporters/serializers/ead3.rb - About 5 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 id_based_slug_for has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def self.id_based_slug_for(entity, klass)
    if klass == Resource || klass == Accession
      if AppConfig[:generate_resource_slugs_with_eadid] && entity[:ead_id] && klass == Resource
        # use EADID if configured. Otherwise, use identifier.
        slug = entity[:ead_id]
Severity: Minor
Found in backend/app/lib/slugs/slug_helpers_generate_by_id.rb - About 5 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 from_endpoint_defn has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    def self.from_endpoint_defn(endpoint, method)
      raise "#{method} not in #{endpoint[:method]}" unless endpoint[:method].include? method
      params = {}
      uri = endpoint[:uri].dup
      endpoint[:params].each do |param_defn|
Severity: Minor
Found in docs/api_doc.rb - About 5 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

Function large_tree has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function (rootNode) {
      self.$container.find('.record-title').attr('href', '#');
      function menuSelectHandler(level) {
        // remove any existing placeholder row
        if (self.inserted_row != undefined) {
Severity: Major
Found in frontend/app/assets/javascripts/archival_objects.crud.js - About 5 hrs to fix

    Method _control has 137 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def _control(json, xml)
        xml.control do
          # AGENT_RECORD_IDENTIFIERS
          with(xml, json['agent_record_identifiers']) do |ari|
            if ari['primary_identifier'] == true
    Severity: Major
    Found in backend/app/exporters/serializers/eac.rb - About 5 hrs to fix

      File top_container.rb has 393 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'uri'
      require 'net/http'
      
      class TopContainer < Sequel::Model(:top_container)
        include ASModel
      Severity: Minor
      Found in backend/app/model/top_container.rb - About 5 hrs to fix

        Method opt has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

          def opt name, desc="", opts={}
            raise ArgumentError, "you already have an argument named '#{name}'" if @specs.member? name
        
            ## fill in :type
            opts[:type] = # normalize
        Severity: Minor
        Found in launcher/backup/lib/trollop.rb - About 5 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 uses_enums has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

            def uses_enums(*definitions)
              definitions.each do |definition|
                Enumeration.register_enumeration_dependant(definition, self)
              end
        
        
        Severity: Minor
        Found in backend/app/model/mixins/dynamic_enums.rb - About 5 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 stringify_date has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.stringify_date(date_json)
              date_substring = ""
        
              if date_json["date_type_structured"] == "single"
                std = date_json["structured_date_single"]['date_standardized']
        Severity: Minor
        Found in backend/app/model/mixins/sort_name_processor.rb - About 5 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 check_row has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_row
            err_arr = []
            begin
              # we'll check hierarchical level first, in case there was a parent that didn't get created
              hier = @row_hash["hierarchy"]
        Severity: Minor
        Found in backend/app/lib/bulk_import/import_archival_objects.rb - About 5 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 create_archival_object has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

          def create_archival_object(parent_uri)
            errs = []
            ao = JSONModel(:archival_object).new._always_valid!
            ao.title = @row_hash["title"] if @row_hash["title"]
            ao.dates = create_dates
        Severity: Minor
        Found in backend/app/lib/bulk_import/import_archival_objects.rb - About 5 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 migrate_agent_rights_statements has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        def migrate_agent_rights_statements
          # Migrate any agent rights statements to a new note type 'Rights Statement'
          # known by the schema note_agent_rights_statement
          #
          # Required fields:
        Severity: Minor
        Found in common/db/migrations/088_rights_management.rb - About 5 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 map_record_fields_to_digital_object has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

          def map_record_fields_to_digital_object(record)
            if ['resource', 'accession', 'archival_object'].include? record['jsonmodel_type']
              record_hash = (record.class == Hash ? record : record.to_hash)
            end
        
        
        Severity: Minor
        Found in frontend/app/helpers/digital_object_helper.rb - About 5 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 start_worker_thread has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

          def start_worker_thread(queue, record_type)
            repo_id = JSONModel.repository
            session = JSONModel::HTTP.current_backend_session
        
            Thread.new do
        Severity: Minor
        Found in indexer/app/lib/periodic_indexer.rb - About 5 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 extract_string_values has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.extract_string_values(doc, *opts)
            return doc, doc if doc.is_a?(String)
        
            if doc.is_a?(Array)
              published_queue = doc.flatten
        Severity: Minor
        Found in indexer/app/lib/indexer_common.rb - About 5 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 map_oai_record has 134 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def map_oai_record(record)
            jsonmodel = record.jsonmodel_record
            result = Nokogiri::XML::Builder.new do |xml|
              xml['oai_dc'].dc('xmlns:oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/',
                               'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
        Severity: Major
        Found in backend/app/lib/oai/mappers/oai_dc.rb - About 5 hrs to fix

          Class MARCModel has 40 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class MARCModel < ASpaceExport::ExportModel
            model_for :marc21
          
            include JSONModel
          
          
          Severity: Minor
          Found in backend/app/exporters/models/marc21.rb - About 5 hrs to fix

            Class JSONModelType has 40 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class JSONModelType
            
              # Class instance variables store the bits specific to this model
              def self.init(type, schema, mixins = [])
                @record_type = type
            Severity: Minor
            Found in common/jsonmodel_type.rb - About 5 hrs to fix

              Function init_subrecord_form has 133 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                $.fn.init_subrecord_form = function () {
                  $(this).each(function () {
                    var $this = $(this);
              
                    if (
              Severity: Major
              Found in frontend/app/assets/javascripts/subrecord_merge.crud.js - About 5 hrs to fix
                Severity
                Category
                Status
                Source
                Language