datacite/bolognese

View on GitHub

Showing 82 of 96 total issues

File utils.rb has 1241 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Bolognese
  module Utils
    class << self
      include Utils
    end
Severity: Major
Found in lib/bolognese/utils.rb - About 3 days to fix

    Method read_datacite has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
    Open

          def read_datacite(string: nil, **options)
            read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
    
            doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
            if read_options.present?
    Severity: Minor
    Found in lib/bolognese/readers/datacite_reader.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 read_datacite has 243 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def read_datacite(string: nil, **options)
            read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
    
            doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
            if read_options.present?
    Severity: Major
    Found in lib/bolognese/readers/datacite_reader.rb - About 1 day to fix

      Method insert_related_items has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
      Open

          def insert_related_items(xml)
            return xml unless related_items.present?
      
            xml.relatedItems do
              related_items.each do |related_item|
      Severity: Minor
      Found in lib/bolognese/datacite_utils.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 read_crossref has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

            def read_crossref(string: nil, **options)
              read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
      
              if string.present?
                m = Maremma.from_xml(string).dig("crossref_result", "query_result", "body", "query", "doi_record") || {}
      Severity: Minor
      Found in lib/bolognese/readers/crossref_reader.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 read_schema_org has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

            def read_schema_org(string: nil, **options)
              if string.present?
                errors = jsonlint(string)
                return { "errors" => errors } if errors.present?
              end
      Severity: Minor
      Found in lib/bolognese/readers/schema_org_reader.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 read_crossref has 154 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def read_crossref(string: nil, **options)
              read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
      
              if string.present?
                m = Maremma.from_xml(string).dig("crossref_result", "query_result", "body", "query", "doi_record") || {}
      Severity: Major
      Found in lib/bolognese/readers/crossref_reader.rb - About 6 hrs to fix

        Method read_schema_org has 138 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def read_schema_org(string: nil, **options)
                if string.present?
                  errors = jsonlint(string)
                  return { "errors" => errors } if errors.present?
                end
        Severity: Major
        Found in lib/bolognese/readers/schema_org_reader.rb - About 5 hrs to fix

          Method get_affiliations has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_affiliations(affiliations)
                Array.wrap(affiliations).map do |a|
                  affiliation_identifier = nil
                  if a.is_a?(String)
                    name = a.squish
          Severity: Minor
          Found in lib/bolognese/author_utils.rb - About 4 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 read_citeproc has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

                def read_citeproc(string: nil, **options)
                  if string.present?
                    errors = jsonlint(string)
                    return { "errors" => errors } if errors.present?
                  end
          Severity: Minor
          Found in lib/bolognese/readers/citeproc_reader.rb - About 4 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 read_bibtex has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

                def read_bibtex(string: nil, **options)
                  read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url, :sandbox, :validate, :ra))
          
                  meta = string.present? ? BibTeX.parse(string).first : OpenStruct.new
          
          
          Severity: Minor
          Found in lib/bolognese/readers/bibtex_reader.rb - About 4 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 Metadata has 34 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Metadata
              include Bolognese::MetadataUtils
          
              attr_accessor :string, :from, :sandbox, :meta, :regenerate, :issue, :show_errors
              attr_reader :doc, :page_start, :page_end
          Severity: Minor
          Found in lib/bolognese/metadata.rb - About 4 hrs to fix

            File datacite_utils.rb has 346 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Bolognese
              module DataciteUtils
                def datacite_xml
                  @datacite_xml ||= Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
                    xml.resource(root_attributes) do
            Severity: Minor
            Found in lib/bolognese/datacite_utils.rb - About 4 hrs to fix

              Method read_codemeta has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                    def read_codemeta(string: nil, **options)
                      if string.present?
                        errors = jsonlint(string)
                        return { "errors" => errors } if errors.present?
                      end
              Severity: Minor
              Found in lib/bolognese/readers/codemeta_reader.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

              File datacite_reader.rb has 316 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Bolognese
                module Readers
                  module DataciteReader
                    def get_datacite(id: nil, **options)
                      return { "string" => nil, "state" => "not_found" } unless id.present?
              Severity: Minor
              Found in lib/bolognese/readers/datacite_reader.rb - About 3 hrs to fix

                Method initialize has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def initialize(options={})
                      options.symbolize_keys!
                      id = normalize_id(options[:input], options)
                      ra = nil
                
                
                Severity: Major
                Found in lib/bolognese/metadata.rb - About 3 hrs to fix

                  File crossref_reader.rb has 312 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module Bolognese
                    module Readers
                      module CrossrefReader
                        # CrossRef types from https://api.crossref.org/types
                        def get_crossref(id: nil, **options)
                  Severity: Minor
                  Found in lib/bolognese/readers/crossref_reader.rb - About 3 hrs to fix

                    Method crossref_people has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def crossref_people(bibliographic_metadata, contributor_role)
                            person = bibliographic_metadata.dig("contributors", "person_name") || bibliographic_metadata.dig("person_name")
                            organization = Array.wrap(bibliographic_metadata.dig("contributors", "organization"))
                            person = [{ "name" => ":(unav)", "contributor_role"=>"author" }] if contributor_role == "author" && Array.wrap(person).select { |a| a["contributor_role"] == "author" }.blank? && Array.wrap(organization).select { |a| a["contributor_role"] == "author" }.blank?
                    
                    
                    Severity: Minor
                    Found in lib/bolognese/readers/crossref_reader.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 read_citeproc has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def read_citeproc(string: nil, **options)
                            if string.present?
                              errors = jsonlint(string)
                              return { "errors" => errors } if errors.present?
                            end
                    Severity: Major
                    Found in lib/bolognese/readers/citeproc_reader.rb - About 3 hrs to fix

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

                          def insert_descriptions(xml)
                            return xml unless descriptions.present? || container && container["title"].present?
                      
                            xml.descriptions do
                              if container && container["title"].present?
                      Severity: Minor
                      Found in lib/bolognese/datacite_utils.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

                      Severity
                      Category
                      Status
                      Source
                      Language