archivesspace/archivesspace

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

Summary

Maintainability
F
1 wk
Test Coverage

Method _cpfdesc has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

  def _cpfdesc(json, xml, obj)
    xml.cpfDescription do
      xml.identity do
        # AGENT_IDENTIFIERS
        with(xml, json['agent_identifiers']) do |ad|
Severity: Minor
Found in backend/app/exporters/serializers/eac.rb - About 1 day 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 eac.rb has 648 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class EACSerializer < ASpaceExport::Serializer
  serializer_for :eac

  def serialize(eac, _opts = {})
    builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
Severity: Major
Found in backend/app/exporters/serializers/eac.rb - About 1 day to fix

    Method _control has a Cognitive Complexity of 66 (exceeds 5 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: Minor
    Found in backend/app/exporters/serializers/eac.rb - About 1 day 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 _cpfdesc has 230 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def _cpfdesc(json, xml, obj)
        xml.cpfDescription do
          xml.identity do
            # AGENT_IDENTIFIERS
            with(xml, json['agent_identifiers']) do |ad|
    Severity: Major
    Found in backend/app/exporters/serializers/eac.rb - About 1 day 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

        Class EACSerializer has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class EACSerializer < ASpaceExport::Serializer
          serializer_for :eac
        
          def serialize(eac, _opts = {})
            builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
        Severity: Minor
        Found in backend/app/exporters/serializers/eac.rb - About 3 hrs to fix

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

            def _build_name_entry(name, xml, _json, obj, parallel = false)
              attrs = {
                'xml:lang' => name['language'],
                'scriptCode' => name['script'],
                'transliteration' => name['transliteration']
          Severity: Minor
          Found in backend/app/exporters/serializers/eac.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 _date_processor has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def _date_processor(date)
              if date['date_type_structured'] == 'single'
                expression   = date['structured_date_single']['date_expression']
                standardized = date['structured_date_single']['date_standardized']
          
          
          Severity: Minor
          Found in backend/app/exporters/serializers/eac.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 _build_date_range_std has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def _build_date_range_std(date, xml)
              begin_expression = date['structured_date_range']['begin_date_expression']
              begin_standardized = date['structured_date_range']['begin_date_standardized']
          
              end_expression = date['structured_date_range']['end_date_expression']
          Severity: Minor
          Found in backend/app/exporters/serializers/eac.rb - About 1 hr to fix

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

              def _subject_subrecord(xml, node, record, attributes = {})
                with(xml, record['subjects']) do |subject|
                  subject = subject['_resolved']
                  # SUBJECT
                  xml.send(node, attributes) do
            Severity: Minor
            Found in backend/app/exporters/serializers/eac.rb - About 1 hr to fix

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

                def _build_name_entry(name, xml, _json, obj, parallel = false)
                  attrs = {
                    'xml:lang' => name['language'],
                    'scriptCode' => name['script'],
                    'transliteration' => name['transliteration']
              Severity: Minor
              Found in backend/app/exporters/serializers/eac.rb - About 1 hr to fix

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

                  def _subject_subrecord(xml, node, record, attributes = {})
                    with(xml, record['subjects']) do |subject|
                      subject = subject['_resolved']
                      # SUBJECT
                      xml.send(node, attributes) do
                Severity: Minor
                Found in backend/app/exporters/serializers/eac.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 _build_name_entry has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def _build_name_entry(name, xml, _json, obj, parallel = false)
                Severity: Minor
                Found in backend/app/exporters/serializers/eac.rb - About 35 mins to fix

                  Method _language_and_script has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def _language_and_script(xml, node, language, script, notes = [])
                  Severity: Minor
                  Found in backend/app/exporters/serializers/eac.rb - About 35 mins to fix

                    Method _language_and_script has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def _language_and_script(xml, node, language, script, notes = [])
                        return unless language || script || notes.any?
                    
                        lang_t = I18n.t("enumerations.language_iso639_2.#{language}")
                        lang_attrs = { 'languageCode' => language }
                    Severity: Minor
                    Found in backend/app/exporters/serializers/eac.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 _build_date_range_std has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def _build_date_range_std(date, xml)
                        begin_expression = date['structured_date_range']['begin_date_expression']
                        begin_standardized = date['structured_date_range']['begin_date_standardized']
                    
                        end_expression = date['structured_date_range']['end_date_expression']
                    Severity: Minor
                    Found in backend/app/exporters/serializers/eac.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 _date_map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def _date_map(dates)
                        return [] unless dates
                    
                        dates.map do |date|
                          date_method = _date_processor(date)
                    Severity: Minor
                    Found in backend/app/exporters/serializers/eac.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

                          within(xml, :sources, json['agent_sources']) do |as|
                            xlink_attrs = {
                              'xlink:href' => as['file_uri'],
                              'xlink:actuate' => as['file_version_xlink_actuate_attribute'],
                              'xlink:show' => as['file_version_xlink_show_attribute'],
                    Severity: Major
                    Found in backend/app/exporters/serializers/eac.rb and 1 other location - About 1 hr to fix
                    backend/app/exporters/serializers/eac.rb on lines 491..506

                    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 68.

                    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

                          within(xml, :alternativeSet, json['agent_alternate_sets']) do |aas|
                            xlink_attrs = {
                              'xlink:href' => aas['file_uri'],
                              'xlink:actuate' => aas['file_version_xlink_actuate_attribute'],
                              'xlink:show' => aas['file_version_xlink_show_attribute'],
                    Severity: Major
                    Found in backend/app/exporters/serializers/eac.rb and 1 other location - About 1 hr to fix
                    backend/app/exporters/serializers/eac.rb on lines 194..209

                    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 68.

                    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

                                with(xml, ar['places']) do |place|
                                  _place(
                                    xml,
                                    place['_resolved']['terms'].first['term'],
                                    place['_resolved']['place_role'],
                    Severity: Minor
                    Found in backend/app/exporters/serializers/eac.rb and 1 other location - About 20 mins to fix
                    backend/app/exporters/serializers/eac.rb on lines 776..781

                    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

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

                            with(xml, record['places']) do |place|
                              _place(
                                xml,
                                place['_resolved']['terms'].first['term'],
                                place['_resolved']['place_role'],
                    Severity: Minor
                    Found in backend/app/exporters/serializers/eac.rb and 1 other location - About 20 mins to fix
                    backend/app/exporters/serializers/eac.rb on lines 416..421

                    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

                    There are no issues that match your filters.

                    Category
                    Status