archivesspace/archivesspace

View on GitHub
backend/app/converters/lib/eac_base_map.rb

Summary

Maintainability
F
6 days
Test Coverage

File eac_base_map.rb has 1132 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module EACBaseMap
  def EAC_BASE_MAP(opts = {:import_events => false})
    import_events = opts[:import_events]

    {
Severity: Major
Found in backend/app/converters/lib/eac_base_map.rb - About 2 days to fix

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

      def agent_date_range_map(label = nil, rel = :dates)
        {
          :obj => :structured_date_label,
          :rel => rel,
          :map => {
    Severity: Minor
    Found in backend/app/converters/lib/eac_base_map.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 agent_person_name_components_map has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def agent_person_name_components_map
        {
           'self::nameEntry[@lang]' => proc { |name, node|
             name[:language] = node.attr('lang')
           },
    Severity: Major
    Found in backend/app/converters/lib/eac_base_map.rb - About 2 hrs to fix

      Method agent_corporate_entity_name_components_map has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def agent_corporate_entity_name_components_map
          {
            'self::nameEntry[@lang]' => proc { |name, node|
              name[:language] = node.attr('lang')
            },
      Severity: Major
      Found in backend/app/converters/lib/eac_base_map.rb - About 2 hrs to fix

        Method agent_family_name_components_map has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def agent_family_name_components_map
            {
              'self::nameEntry[@lang]' => proc { |name, node|
                name[:language] = node.attr('lang')
              },
        Severity: Major
        Found in backend/app/converters/lib/eac_base_map.rb - About 2 hrs to fix

          Method agent_date_range_map has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def agent_date_range_map(label = nil, rel = :dates)
              {
                :obj => :structured_date_label,
                :rel => rel,
                :map => {
          Severity: Minor
          Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

            Method agent_record_control_map has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def agent_record_control_map
                {
                  :obj => :agent_record_control,
                  :rel => :agent_record_controls,
                  :map => {
            Severity: Minor
            Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

              Method related_resource_map has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def related_resource_map
                  {
                    :obj => :agent_resource,
                    :rel => :agent_resources,
                    :map => {
              Severity: Minor
              Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

                Method agent_date_single_map has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def agent_date_single_map(label = nil, rel = :dates)
                    {
                      :obj => :structured_date_label,
                      :rel => rel,
                      :map => {
                Severity: Minor
                Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

                  Method related_agent_map has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def related_agent_map(type)
                      {
                        :obj => :"agent_#{type}",
                        :rel => proc { |agent, rel_agent|
                          agent[:related_agents] << {
                  Severity: Minor
                  Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

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

                      def agent_date_single_map(label = nil, rel = :dates)
                        {
                          :obj => :structured_date_label,
                          :rel => rel,
                          :map => {
                    Severity: Minor
                    Found in backend/app/converters/lib/eac_base_map.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 agent_bioghist_note_map has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def agent_bioghist_note_map
                        {
                          :obj => :note_bioghist,
                          :rel => :notes,
                          :map => {
                    Severity: Minor
                    Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

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

                        def find_relationship(node, type)
                          relationship = node.attr('cpfRelationType')
                      
                          case relationship
                          when 'identity'
                      Severity: Minor
                      Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

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

                          def agent_maintenance_history_map
                            {
                              :obj => :agent_maintenance_history,
                              :rel => :agent_maintenance_histories,
                              :map => {
                        Severity: Minor
                        Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

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

                            def base_map_subfields(import_events)
                              h = {
                                '//eac-cpf//control/recordId' => agent_record_identifiers_map,
                                '//eac-cpf//control/otherRecordId' => agent_other_record_identifiers_map,
                                '//eac-cpf//control' => agent_record_control_map,
                          Severity: Minor
                          Found in backend/app/converters/lib/eac_base_map.rb - About 1 hr to fix

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

                              def create_chron_item(node)
                                items = []
                                node.search('./chronItem').each do |n|
                                  if (d = n.at_xpath('dateRange'))
                                    date = format_content(d.at_xpath('fromDate').inner_text)
                            Severity: Minor
                            Found in backend/app/converters/lib/eac_base_map.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 hierarchical_relationship has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def hierarchical_relationship(hierarchy, node, type)
                                if pers_match?(node, type) || fam_match?(node, type)
                                  case hierarchy
                                  when 'parent'
                                    relator = 'is_parent_of'
                            Severity: Minor
                            Found in backend/app/converters/lib/eac_base_map.rb - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

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

                                    'self::source' => proc { |s, node|
                                      s[:file_uri] = node.attr('href')
                                      s[:file_version_xlink_actuate_attribute] = node.attr('actuate')
                                      s[:file_version_xlink_show_attribute] = node.attr('show')
                                      s[:xlink_title_attribute] = node.attr('title')
                            Severity: Minor
                            Found in backend/app/converters/lib/eac_base_map.rb and 1 other location - About 55 mins to fix
                            backend/app/converters/lib/eac_base_map.rb on lines 504..511

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

                            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

                                    'self::setComponent' => proc { |as, node|
                                      as[:file_uri] = node.attr('href')
                                      as[:file_version_xlink_actuate_attribute] = node.attr('actuate')
                                      as[:file_version_xlink_show_attribute] = node.attr('show')
                                      as[:xlink_title_attribute] = node.attr('title')
                            Severity: Minor
                            Found in backend/app/converters/lib/eac_base_map.rb and 1 other location - About 55 mins to fix
                            backend/app/converters/lib/eac_base_map.rb on lines 564..571

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

                            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 agent_legal_status_note_map
                                {
                                  :obj => :note_legal_status,
                                  :rel => :notes,
                                  :map => {
                            Severity: Minor
                            Found in backend/app/converters/lib/eac_base_map.rb and 1 other location - About 50 mins to fix
                            backend/app/converters/lib/eac_base_map.rb on lines 974..992

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

                            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 agent_mandate_note_map
                                {
                                  :obj => :note_mandate,
                                  :rel => :notes,
                                  :map => {
                            Severity: Minor
                            Found in backend/app/converters/lib/eac_base_map.rb and 1 other location - About 50 mins to fix
                            backend/app/converters/lib/eac_base_map.rb on lines 951..969

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

                            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 agent_structure_note_map
                                {
                                  :obj => :note_structure_or_genealogy,
                                  :rel => :notes,
                                  :map => {
                            Severity: Minor
                            Found in backend/app/converters/lib/eac_base_map.rb and 1 other location - About 15 mins to fix
                            backend/app/converters/lib/eac_base_map.rb on lines 917..929

                            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

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

                              def agent_general_context_note_map
                                {
                                  :obj => :note_general_context,
                                  :rel => :notes,
                                  :map => {
                            Severity: Minor
                            Found in backend/app/converters/lib/eac_base_map.rb and 1 other location - About 15 mins to fix
                            backend/app/converters/lib/eac_base_map.rb on lines 934..946

                            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

                            There are no issues that match your filters.

                            Category
                            Status