archivesspace/archivesspace

View on GitHub
backend/app/exporters/serializers/ead.rb

Summary

Maintainability
F
2 wks
Test Coverage

Method serialize_eadheader has a Cognitive Complexity of 109 (exceeds 5 allowed). Consider refactoring.
Open

  def serialize_eadheader(data, xml, fragments)
    eadid_url = data.ead_location

    if AppConfig[:arks_enabled] && data.ark_name && (current_ark = data.ark_name.fetch('current', nil))
      eadid_url = current_ark
Severity: Minor
Found in backend/app/exporters/serializers/ead.rb - About 2 days 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

File ead.rb has 785 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'nokogiri'
require 'securerandom'
require 'cgi'

class EADSerializer < ASpaceExport::Serializer
Severity: Major
Found in backend/app/exporters/serializers/ead.rb - About 1 day to fix

    Method serialize_digital_object has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

      def serialize_digital_object(digital_object, xml, fragments)
        return if digital_object["publish"] === false && !@include_unpublished
        return if digital_object["suppressed"] === true
    
        # ANW-285: Only serialize file versions that are published, unless include_unpublished flag is set
    Severity: Minor
    Found in backend/app/exporters/serializers/ead.rb - About 7 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_subnotes has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

      def serialize_subnotes(subnotes, xml, fragments, include_p = true)
        subnotes.each do |sn|
          next if sn["publish"] === false && !@include_unpublished
    
          audatt = sn["publish"] === false ? {:audience => 'internal'} : {}
    Severity: Minor
    Found in backend/app/exporters/serializers/ead.rb - About 7 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_languages has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

      def serialize_languages(languages, xml, fragments)
        lm = []
        language_notes = languages.map {|l| l['notes']}.compact.reject {|e| e == [] }.flatten
        if !language_notes.empty?
          language_notes.each do |note|
    Severity: Minor
    Found in backend/app/exporters/serializers/ead.rb - About 6 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
          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_eadheader has 127 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def serialize_eadheader(data, xml, fragments)
        eadid_url = data.ead_location
    
        if AppConfig[:arks_enabled] && data.ark_name && (current_ark = data.ark_name.fetch('current', nil))
          eadid_url = current_ark
    Severity: Major
    Found in backend/app/exporters/serializers/ead.rb - About 5 hrs to fix

      Method stream has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def stream(data)
          @stream_handler = ASpaceExport::StreamHandler.new
          @fragments = ASpaceExport::RawXMLHandler.new
          @include_unpublished = data.include_unpublished?
          @include_daos = data.include_daos?
      Severity: Minor
      Found in backend/app/exporters/serializers/ead.rb - About 3 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_extents has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def serialize_extents(obj, xml, fragments)
          if obj.extents.length
            obj.extents.each do |e|
              next if e["publish"] === false && !@include_unpublished
              audatt = e["publish"] === false ? {:audience => 'internal'} : {}
      Severity: Minor
      Found in backend/app/exporters/serializers/ead.rb - About 3 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 EADSerializer has 30 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class EADSerializer < ASpaceExport::Serializer
        serializer_for :ead
      
        # Allow plugins to hook in to record processing by providing their own
        # serialization step (a class with a 'call' method accepting the arguments
      Severity: Minor
      Found in backend/app/exporters/serializers/ead.rb - About 3 hrs to fix

        Method stream has 78 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def stream(data)
            @stream_handler = ASpaceExport::StreamHandler.new
            @fragments = ASpaceExport::RawXMLHandler.new
            @include_unpublished = data.include_unpublished?
            @include_daos = data.include_daos?
        Severity: Major
        Found in backend/app/exporters/serializers/ead.rb - About 3 hrs to fix

          Method serialize_child has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

            def serialize_child(data, xml, fragments, c_depth = 1)
              return if data["publish"] === false && !@include_unpublished
              return if data["suppressed"] === true
          
              tag_name = @use_numbered_c_tags ? :"c#{c_depth.to_s.rjust(2, '0')}" : :c
          Severity: Minor
          Found in backend/app/exporters/serializers/ead.rb - About 3 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_did_notes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            def serialize_did_notes(data, xml, fragments)
              data.notes.each do |note|
                next if note["publish"] === false && !@include_unpublished
                next unless data.did_note_types.include?(note['type'])
          
          
          Severity: Minor
          Found in backend/app/exporters/serializers/ead.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 serialize_nondid_notes has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

            def serialize_nondid_notes(data, xml, fragments)
              data.notes.each do |note|
                next if note["publish"] === false && !@include_unpublished
                next if note['internal']
                next if note['type'].nil?
          Severity: Minor
          Found in backend/app/exporters/serializers/ead.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 serialize_bibliographies has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def serialize_bibliographies(data, xml, fragments)
              data.bibliographies.each do |note|
                next if note["publish"] === false && !@include_unpublished
                content = ASpaceExport::Utils.extract_note_text(note, @include_unpublished)
                note_type = note["type"] ? note["type"] : "bibliography"
          Severity: Minor
          Found in backend/app/exporters/serializers/ead.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 serialize_digital_object has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def serialize_digital_object(digital_object, xml, fragments)
              return if digital_object["publish"] === false && !@include_unpublished
              return if digital_object["suppressed"] === true
          
              # ANW-285: Only serialize file versions that are published, unless include_unpublished flag is set
          Severity: Major
          Found in backend/app/exporters/serializers/ead.rb - About 2 hrs to fix

            Method serialize_origination has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

              def serialize_origination(data, xml, fragments)
                unless data.creators_and_sources.nil?
                  data.creators_and_sources.each do |link|
                    agent = link['_resolved']
                    published = agent['publish'] === true
            Severity: Minor
            Found in backend/app/exporters/serializers/ead.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 serialize_languages has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def serialize_languages(languages, xml, fragments)
                lm = []
                language_notes = languages.map {|l| l['notes']}.compact.reject {|e| e == [] }.flatten
                if !language_notes.empty?
                  language_notes.each do |note|
            Severity: Major
            Found in backend/app/exporters/serializers/ead.rb - About 2 hrs to fix

              Method serialize_child has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def serialize_child(data, xml, fragments, c_depth = 1)
                  return if data["publish"] === false && !@include_unpublished
                  return if data["suppressed"] === true
              
                  tag_name = @use_numbered_c_tags ? :"c#{c_depth.to_s.rjust(2, '0')}" : :c
              Severity: Major
              Found in backend/app/exporters/serializers/ead.rb - About 2 hrs to fix

                Method serialize_subnotes has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def serialize_subnotes(subnotes, xml, fragments, include_p = true)
                    subnotes.each do |sn|
                      next if sn["publish"] === false && !@include_unpublished
                
                      audatt = sn["publish"] === false ? {:audience => 'internal'} : {}
                Severity: Minor
                Found in backend/app/exporters/serializers/ead.rb - About 1 hr to fix

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

                    def serialize_note_content(note, xml, fragments)
                      return if note["publish"] === false && !@include_unpublished
                      audatt = note["publish"] === false ? {:audience => 'internal'} : {}
                      content = note["content"]
                  
                  
                  Severity: Minor
                  Found in backend/app/exporters/serializers/ead.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 serialize_indexes has 31 lines of code (exceeds 25 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 1 hr to fix

                    Method serialize_origination has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def serialize_origination(data, xml, fragments)
                        unless data.creators_and_sources.nil?
                          data.creators_and_sources.each do |link|
                            agent = link['_resolved']
                            published = agent['publish'] === true
                    Severity: Minor
                    Found in backend/app/exporters/serializers/ead.rb - About 1 hr to fix

                      Method serialize_container has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def serialize_container(inst, xml, fragments)
                          atts = {}
                      
                          sub = inst['sub_container']
                          top = sub['top_container']['_resolved']
                      Severity: Minor
                      Found in backend/app/exporters/serializers/ead.rb - About 1 hr to fix

                        Method serialize_did_notes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def serialize_did_notes(data, xml, fragments)
                            data.notes.each do |note|
                              next if note["publish"] === false && !@include_unpublished
                              next unless data.did_note_types.include?(note['type'])
                        
                        
                        Severity: Minor
                        Found in backend/app/exporters/serializers/ead.rb - About 1 hr to fix

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

                            def serialize_container(inst, xml, fragments)
                              atts = {}
                          
                              sub = inst['sub_container']
                              top = sub['top_container']['_resolved']
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.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 serialize_dates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def serialize_dates(obj, xml, fragments)
                              obj.archdesc_dates.each do |node_data|
                                next if node_data["publish"] === false && !@include_unpublished
                                audatt = node_data["publish"] === false ? {:audience => 'internal'} : {}
                                xml.unitdate(node_data[:atts].merge(audatt)) {
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.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

                          Method handle_linebreaks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def handle_linebreaks(content)
                              # 4archon...
                              content.gsub!("\n\t", "\n\n")
                              # if there's already p tags, just leave as is
                              return content if ( content.strip =~ /^<p(\s|\/|>)/ or content.strip.length < 1 )
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.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

                          Method serialize_controlaccess has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def serialize_controlaccess(data, xml, fragments)
                              if (data.controlaccess_subjects.length + data.controlaccess_linked_agents(@include_unpublished).reject {|x| x.empty?}.length) > 0
                                xml.controlaccess {
                                  data.controlaccess_subjects.zip(data.subjects).each do |node_data, subject|
                                    xml.send(node_data[:node_name], node_data[:atts]) {
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.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

                          Method sanitize_mixed_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def sanitize_mixed_content(content, context, fragments, allow_p = false )
                              # remove smart quotes from text
                              content = remove_smart_quotes(content)
                          
                              # br's should be self closing
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.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

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                when 'note_chronology'
                                  xml.chronlist(audatt) {
                                    xml.head { sanitize_mixed_content(title, xml, fragments) } if title
                          
                                    sn['items'].each do |item|
                          Severity: Major
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 1 hr to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1322..1337

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 65.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                            def handle_arks(data, xml)
                              return unless AppConfig[:arks_enabled]
                              return unless data.ark_name
                          
                              if current_ark = data.ark_name.fetch('current', nil)
                          Severity: Major
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 1 hr to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1237..1259

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 64.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  xml.langmaterial {
                                    languages.map {|language|
                                      punctuation = language.equal?(languages.last) ? '.' : ', '
                                      lang_translation = I18n.t("enumerations.language_iso639_2.#{language['language']}", :default => language['language'])
                                      if language['script']
                          Severity: Major
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 1 hr to fix
                          backend/app/exporters/serializers/ead.rb on lines 720..733

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 62.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  xml.langmaterial {
                                    languages.map {|language|
                                      punctuation = language.equal?(languages.last) ? '.' : ', '
                                      lang_translation = I18n.t("enumerations.language_iso639_2.#{language['language']}", :default => language['language'])
                                      if language['script']
                          Severity: Major
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 1 hr to fix
                          backend/app/exporters/serializers/ead.rb on lines 699..712

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 62.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                when 'note_definedlist'
                                  xml.list({:type => 'deflist'}.merge(audatt)) {
                                    xml.head { sanitize_mixed_content(title, xml, fragments) } if title
                          
                                    sn['items'].each do |item|
                          Severity: Major
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 1 hr to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1353..1360

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 57.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                              xml.send(note['type'], atts) {
                                xml.head { sanitize_mixed_content(head_text, xml, fragments) } unless ASpaceExport::Utils.headless_note?(note['type'], content )
                                sanitize_mixed_content(content, xml, fragments, ASpaceExport::Utils.include_p?(note['type']) ) if content
                                if note['subnotes']
                                  serialize_subnotes(note['subnotes'], xml, fragments, ASpaceExport::Utils.include_p?(note['type']))
                          Severity: Major
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 1 hr to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1084..1088

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 51.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              (2..3).each do |n|
                                atts = {}
                          
                                next unless sub["type_#{n}"]
                          
                          
                          Severity: Major
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 1 hr to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1395..1408

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 50.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                              if date['expression']
                                content << date['expression']
                              elsif date['begin']
                                content << date['begin']
                                if date['end'] != date['begin']
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 35 mins to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1438..1445

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 34.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                xml.bibliography(atts) {
                                  xml.head { sanitize_mixed_content(head_text, xml, fragments) }
                                  sanitize_mixed_content( content, xml, fragments, true)
                                  note['items'].each do |item|
                                    xml.bibref { sanitize_mixed_content( item, xml, fragments) } unless item.empty?
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 30 mins to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1496..1500

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 33.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                    xml.send(node_data[:node_name], node_data[:atts]) {
                                      sanitize_mixed_content( node_data[:content], xml, fragments, ASpaceExport::Utils.include_p?(node_data[:node_name]) )
                                      EADSerializer.run_serialize_step(agent['_resolved'], xml, fragments, node_data[:node_name].to_sym)
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 30 mins to fix
                          backend/app/exporters/serializers/ead.rb on lines 415..417

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 33.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                    xml.send(node_data[:node_name], node_data[:atts]) {
                                      sanitize_mixed_content( node_data[:content], xml, fragments, ASpaceExport::Utils.include_p?(node_data[:node_name]) )
                                      EADSerializer.run_serialize_step(subject['_resolved'], xml, fragments, node_data[:node_name].to_sym)
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 30 mins to fix
                          backend/app/exporters/serializers/ead.rb on lines 423..425

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 33.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                            def extract_head_text(content, backup = "")
                              content ||= ""
                              match = content.strip.match(/<head( [^<>]+)?>(.+?)<\/head>/)
                              if match.nil? # content has no head so we return it as it
                                return [content, backup ]
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 25 mins to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1142..1148

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 30.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  xml.list(atts) {
                                    xml.head { sanitize_mixed_content(title, xml, fragments) } if title
                          
                                    sn['items'].each do |item|
                                      xml.item { sanitize_mixed_content(item, xml, fragments)}
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 20 mins to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1346..1350

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 27.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 4 locations. Consider refactoring.
                          Open

                                  if @include_unpublished
                                    data.external_ids.each do |exid|
                                      xml.unitid ({ "audience" => "internal", "type" => exid['source'], "identifier" => exid['external_id']}) { xml.text exid['external_id']}
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 3 other locations - About 15 mins to fix
                          backend/app/exporters/serializers/ead.rb on lines 188..190
                          backend/app/exporters/serializers/ead3.rb on lines 517..519
                          backend/app/exporters/serializers/ead3.rb on lines 1182..1184

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 26.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 4 locations. Consider refactoring.
                          Open

                                      if @include_unpublished
                                        data.external_ids.each do |exid|
                                          xml.unitid ({ "audience" => "internal", "type" => exid['source'], "identifier" => exid['external_id']}) { xml.text exid['external_id']}
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 3 other locations - About 15 mins to fix
                          backend/app/exporters/serializers/ead.rb on lines 326..328
                          backend/app/exporters/serializers/ead3.rb on lines 517..519
                          backend/app/exporters/serializers/ead3.rb on lines 1182..1184

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 26.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                            def prefix_id(id)
                              if id.nil? or id.empty? or id == 'null'
                                ""
                              elsif id =~ /^#{@id_prefix}/
                                id
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 15 mins to fix
                          backend/app/exporters/serializers/ead3.rb on lines 144..151

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 25.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                if note['label']
                                  head_text = note['label']
                                elsif note['type']
                                  head_text = I18n.t("enumerations._note_types.#{note['type']}", :default => note['type'])
                                end
                          Severity: Minor
                          Found in backend/app/exporters/serializers/ead.rb and 1 other location - About 15 mins to fix
                          backend/app/exporters/serializers/ead3.rb on lines 1513..1517

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 25.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          There are no issues that match your filters.

                          Category
                          Status