relaton/relaton

View on GitHub

Showing 10 of 10 total issues

Class Db has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Db
    # @param global_cache [String] directory of global DB
    # @param local_cache [String] directory of local DB
    def initialize(global_cache, local_cache)
      @registry = Relaton::Registry.instance
Severity: Minor
Found in lib/relaton/db.rb - About 4 hrs to fix

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

        def check_bibliocache(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
          id, searchcode = std_id(code, year, opts, stdclass)
          db = @local_db || @db
          altdb = @local_db && @db ? @db : nil
          if db.nil?
    Severity: Minor
    Found in lib/relaton/db.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 db.rb has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Relaton
      class Db
        # @param global_cache [String] directory of global DB
        # @param local_cache [String] directory of local DB
        def initialize(global_cache, local_cache)
    Severity: Minor
    Found in lib/relaton/db.rb - About 2 hrs to fix

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

          def fetch_async(ref, year = nil, opts = {}, &block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
            stdclass = @registry.class_by_ref ref
            if stdclass
              unless @queues[stdclass]
                processor = @registry.processors[stdclass]
      Severity: Minor
      Found in lib/relaton/db.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 combine_doc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def combine_doc(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
            return if stdclass == :relaton_bipm
      
            if (refs = code.split " + ").size > 1
              reltype = "derivedFrom"
      Severity: Minor
      Found in lib/relaton/db.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 search_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def search_xml(file, xml, text, edition, year)
      Severity: Minor
      Found in lib/relaton/db.rb - About 35 mins to fix

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

            def net_retry(code, year, opts, processor, retries)
        Severity: Minor
        Found in lib/relaton/db.rb - About 35 mins to fix

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

              def fetch_entry(code, year, opts, stdclass, **args)
          Severity: Minor
          Found in lib/relaton/db.rb - About 35 mins to fix

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

                def new_bib_entry(code, year, opts, stdclass, **args)
            Severity: Minor
            Found in lib/relaton/db.rb - About 35 mins to fix

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

                  def search_edition_year(file, content, edition, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
                    processor = @registry.processor_by_ref(file.split("/")[-2])
                    item = if file.match?(/xml$/) then processor.from_xml(content)
                           else processor.hash_to_bib(YAML.safe_load(content))
                           end
              Severity: Minor
              Found in lib/relaton/db.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

              Severity
              Category
              Status
              Source
              Language