datacite/cirneco

View on GitHub

Showing 11 of 21 total issues

Method bulk_state_change has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def bulk_state_change(file)
      count = 0
      File.foreach(file) do |line|
        doi = line.rstrip
        next unless doi.present?
Severity: Minor
Found in lib/cirneco/doi.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 bulk_state_change has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def bulk_state_change(file)
      count = 0
      File.foreach(file) do |line|
        doi = line.rstrip
        next unless doi.present?
Severity: Minor
Found in lib/cirneco/doi.rb - About 1 hr to fix

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

        def update_rest_doi(doi, options={})
          return OpenStruct.new(body: { "errors" => [{ "title" => "JWT or Username or password missing" }] }) unless options[:jwt].present? || (options[:username].present? && options[:password].present?)
    
          api_url = options[:sandbox] ? 'https://api.test.datacite.org' : 'https://api.datacite.org'
    
    
    Severity: Minor
    Found in lib/cirneco/api.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 transfer_doi has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def transfer_doi(doi, options={})
          return OpenStruct.new(body: { "errors" => [{ "title" => "JWT or Username or password missing" }] }) unless options[:jwt].present? || (options[:username].present? && options[:password].present?)
    
          api_url = options[:sandbox] ? 'https://api.test.datacite.org' : 'https://api.datacite.org'
    
    
    Severity: Minor
    Found in lib/cirneco/api.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 post has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def post(file)
          data = JSON.parse(IO.read(file))
          count = 0
          data.each do |json|
            doi = doi_from_url(json["@id"])
    Severity: Minor
    Found in lib/cirneco/doi.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 post_media has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def post_media(doi, options={})
          return OpenStruct.new(body: { "errors" => [{ "title" => "Username or password missing" }] }) unless options[:username].present? && options[:password].present?
    
          payload = options[:raw] ? options[:media] : options[:media].map { |m| "#{m[:mime_type]}=#{m[:url]}" }.join("\n")
    
    
    Severity: Minor
    Found in lib/cirneco/api.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 put has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def put(file)
          data = JSON.parse(IO.read(file))
          count = 0
          data.each do |json|
            doi = doi_from_url(json["@id"])
    Severity: Minor
    Found in lib/cirneco/metadata.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 transfer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def transfer(file)
          count = 0
          File.foreach(file) do |line|
            doi = line.rstrip
            next unless doi.present?
    Severity: Minor
    Found in lib/cirneco/doi.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 generate_accession_number has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_accession_number(options={})
          lower_limit = options[:lower_limit] || 0
          namespace = options[:namespace] || 'MS-'
          registered_numbers = options[:registered_numbers] || []
    
    
    Severity: Minor
    Found in lib/cirneco/utils.rb - About 25 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 get_dois has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_dois(options={})
          return OpenStruct.new(body: { "errors" => [{ "title" => "Username or password missing" }] }) unless options[:username].present? && options[:password].present?
    
          mds_url = options[:sandbox] ? 'https://mds.test.datacite.org' : 'https://mds.datacite.org'
    
    
    Severity: Minor
    Found in lib/cirneco/api.rb - About 25 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 get_media has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_media(doi, options={})
          return OpenStruct.new(body: { "errors" => [{ "title" => "Username or password missing" }] }) unless options[:username].present? && options[:password].present?
    
          mds_url = options[:sandbox] ? 'https://mds.test.datacite.org' : 'https://mds.datacite.org'
    
    
    Severity: Minor
    Found in lib/cirneco/api.rb - About 25 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