datacite/toccatore

View on GitHub

Showing 11 of 13 total issues

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

  class Base
    # icon for Slack messages
    ICON_URL = "https://raw.githubusercontent.com/datacite/toccatore/master/lib/toccatore/images/toccatore.png"

    # load ENV variables from .env file if it exists
Severity: Minor
Found in lib/toccatore/base.rb - About 3 hrs to fix

    Method parse_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_data(result, options={})
          return result.body.fetch("errors") if result.body.fetch("errors", nil).present?
    
          items = result.body.fetch("data", {}).fetch('response', {}).fetch('docs', nil)
          registration_agencies = {}
    Severity: Minor
    Found in lib/toccatore/datacite_related.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 parse_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_data(result, options={})
          return result.body.fetch("errors") if result.body.fetch("errors", nil).present?
    
          items = result.body.fetch("data", {}).fetch('response', {}).fetch('docs', nil)
          claim_action = options[:claim_action].presence || "create"
    Severity: Minor
    Found in lib/toccatore/orcid_update.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 push_item has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def push_item(item, options={})
          if options[:access_token].blank?
            puts "Access token missing."
            return 1
          end
    Severity: Minor
    Found in lib/toccatore/datacite_related.rb - About 1 hr to fix

      Method queue_jobs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def queue_jobs(options={})
            options[:offset] = options[:offset].to_i || 0
            options[:rows] = options[:rows].presence || job_batch_size
            options[:from_date] = options[:from_date].presence || (Time.now.to_date - 1.day).iso8601
            options[:until_date] = options[:until_date].presence || Time.now.to_date.iso8601
      Severity: Minor
      Found in lib/toccatore/base.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 parse_data has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def parse_data(result, options={})
            return result.body.fetch("errors") if result.body.fetch("errors", nil).present?
      
            items = result.body.fetch("data", {}).fetch('response', {}).fetch('docs', nil)
            registration_agencies = {}
      Severity: Minor
      Found in lib/toccatore/datacite_related.rb - About 1 hr to fix

        Method queue_jobs has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def queue_jobs(options={})
              options[:offset] = options[:offset].to_i || 0
              options[:rows] = options[:rows].presence || job_batch_size
              options[:from_date] = options[:from_date].presence || (Time.now.to_date - 1.day).iso8601
              options[:until_date] = options[:until_date].presence || Time.now.to_date.iso8601
        Severity: Minor
        Found in lib/toccatore/base.rb - About 1 hr to fix

          Method push_item has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def push_item(item, options={})
                if item["subj-id"].blank?
                  puts OpenStruct.new(body: { "errors" => [{ "title" => "There is no Subject" }] })
                  return 1
                elsif options[:access_token].blank?
          Severity: Minor
          Found in lib/toccatore/usage_update.rb - About 1 hr to fix

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

                def queue_jobs(options={})
            
                  total = get_total(options)
                  
                  if total < 1
            Severity: Minor
            Found in lib/toccatore/usage_update.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 push_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def push_item(item, options={})
                  if item["subj-id"].blank?
                    puts OpenStruct.new(body: { "errors" => [{ "title" => "There is no Subject" }] })
                    return 1
                  elsif options[:access_token].blank?
            Severity: Minor
            Found in lib/toccatore/usage_update.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 push_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def push_item(item, options={})
                  if options[:access_token].blank?
                    puts "Access token missing."
                    return 1
                  end
            Severity: Minor
            Found in lib/toccatore/datacite_related.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