lulibrary/puree

View on GitHub

Showing 44 of 44 total issues

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

    class ResearchOutput < Puree::XMLExtractor::Resource
      include Puree::XMLExtractor::AbstractMixin
      include Puree::XMLExtractor::KeywordMixin
      include Puree::XMLExtractor::OrganisationalUnitMixin
      include Puree::XMLExtractor::OwnerMixin
Severity: Minor
Found in lib/puree/xml_extractor/research_output.rb - About 2 hrs to fix

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

        class Base
    
          # @param config [Hash]
          # @option config [String] :url URL of the Pure host
          # @option config [String] :username Username of the Pure host account
    Severity: Minor
    Found in lib/puree/rest/base.rb - About 2 hrs to fix

      Method address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def address
              xpath_result = xpath_query '/addresses/address'
              if !xpath_result.empty?
                a = Puree::Model::Address.new
                street = xpath_result.xpath('street').text.strip
      Severity: Minor
      Found in lib/puree/xml_extractor/organisational_unit.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 persons has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def persons(type, xpath_query_path)
              xpath_result = xpath_query xpath_query_path
              arr = []
              xpath_result.each do |i|
                uuid_internal = i.at_xpath('person/@uuid')
      Severity: Minor
      Found in lib/puree/xml_extractor/mixins/person_mixin.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 normalise has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.normalise(data)
              if !data.nil? && !data.empty?
                date = {}
                year =  data['year']
                month = data['month']
      Severity: Minor
      Found in lib/puree/util/date.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

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

        module XMLExtractor
      
          # Research output extractor mixin.
          #
          module ResearchOutputMixin
      Severity: Major
      Found in lib/puree/xml_extractor/mixins/research_output_mixin.rb and 1 other location - About 1 hr to fix
      lib/puree/xml_extractor/mixins/project_mixin.rb on lines 3..23

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

      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

        module XMLExtractor
      
          # Project extractor mixin.
          #
          module ProjectMixin
      Severity: Major
      Found in lib/puree/xml_extractor/mixins/project_mixin.rb and 1 other location - About 1 hr to fix
      lib/puree/xml_extractor/mixins/research_output_mixin.rb on lines 3..23

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

      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

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

            def self.research_outputs(xml)
              path_from_root = File.join 'result/items', '/*'
              doc = Nokogiri::XML xml
              doc.remove_namespaces!
              xpath_result = doc.xpath path_from_root
      Severity: Minor
      Found in lib/puree/xml_extractor/collection.rb - About 1 hr to fix

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

              def combine_metadata
                super
                @model.bibliographical_note = bibliographical_note
                @model.category = category
                @model.description = description
        Severity: Minor
        Found in lib/puree/xml_extractor/research_output.rb - About 1 hr to fix

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

                def persons(type, xpath_query_path)
                  xpath_result = xpath_query xpath_query_path
                  arr = []
                  xpath_result.each do |i|
                    uuid_internal = i.at_xpath('person/@uuid')
          Severity: Minor
          Found in lib/puree/xml_extractor/mixins/person_mixin.rb - About 1 hr to fix

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

                  def self.external_organisation_header(nokogiri_xml_element)
                    h = Puree::Model::ExternalOrganisationHeader.new
                    h.uuid = nokogiri_xml_element.xpath('@uuid').text.strip
                    xpath_result_name = nokogiri_xml_element.xpath('name/text')
                    h.name = xpath_result_name.first.text.strip unless xpath_result_name.empty?
            Severity: Minor
            Found in lib/puree/xml_extractor/shared.rb and 1 other location - About 55 mins to fix
            lib/puree/xml_extractor/shared.rb on lines 31..39

            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 self.organisation_header(nokogiri_xml_element)
                    h = Puree::Model::OrganisationalUnitHeader.new
                    h.uuid = nokogiri_xml_element.xpath('@uuid').text.strip
                    xpath_result_name = nokogiri_xml_element.xpath('name/text')
                    h.name = xpath_result_name.first.text.strip unless xpath_result_name.empty?
            Severity: Minor
            Found in lib/puree/xml_extractor/shared.rb and 1 other location - About 55 mins to fix
            lib/puree/xml_extractor/shared.rb on lines 10..18

            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

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

                  def self.iso(data)
                    iso_date = ''
                    year =  data['year']
                    month = data['month']
                    day = data['day']
            Severity: Minor
            Found in lib/puree/util/date.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

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

              module Model
            
                # A minimal representation of related content.
                #
                class RelatedContentHeader < Puree::Model::Structure
            Severity: Major
            Found in lib/puree/model/related_content_header.rb and 2 other locations - About 45 mins to fix
            lib/puree/model/journal_header.rb on lines 2..30
            lib/puree/model/organisation_header_base.rb on lines 2..30

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

            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 3 locations. Consider refactoring.
            Open

              module Model
            
                # A minimal representation of a journal.
                #
                class JournalHeader < Puree::Model::Structure
            Severity: Major
            Found in lib/puree/model/journal_header.rb and 2 other locations - About 45 mins to fix
            lib/puree/model/organisation_header_base.rb on lines 2..30
            lib/puree/model/related_content_header.rb on lines 2..30

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

            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 3 locations. Consider refactoring.
            Open

              module Model
            
                # A minimal representation of an external organisation.
                #
                class OrganisationHeaderBase < Puree::Model::Structure
            Severity: Major
            Found in lib/puree/model/organisation_header_base.rb and 2 other locations - About 45 mins to fix
            lib/puree/model/journal_header.rb on lines 2..30
            lib/puree/model/related_content_header.rb on lines 2..30

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

            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

            Method research_outputs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.research_outputs(xml)
                    path_from_root = File.join 'result/items', '/*'
                    doc = Nokogiri::XML xml
                    doc.remove_namespaces!
                    xpath_result = doc.xpath path_from_root
            Severity: Minor
            Found in lib/puree/xml_extractor/collection.rb - About 45 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                  def name
                    xpath_result = xpath_query '/name'
                    if !xpath_result.empty?
                      first = xpath_result.xpath('firstName').text.strip
                      last = xpath_result.xpath('lastName').text.strip
            Severity: Minor
            Found in lib/puree/xml_extractor/person.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

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

              module XMLExtractor
            
                # External organisation XML extractor.
                #
                class ExternalOrganisation < Puree::XMLExtractor::Resource
            Severity: Minor
            Found in lib/puree/xml_extractor/external_organisation.rb and 1 other location - About 30 mins to fix
            lib/puree/xml_extractor/publisher.rb on lines 3..30

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

            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

              module XMLExtractor
            
                # Publisher XML extractor.
                #
                class Publisher < Puree::XMLExtractor::Resource
            Severity: Minor
            Found in lib/puree/xml_extractor/publisher.rb and 1 other location - About 30 mins to fix
            lib/puree/xml_extractor/external_organisation.rb on lines 3..30

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

            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

            Severity
            Category
            Status
            Source
            Language