File helpable.rb
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Helpable
extend ActiveSupport::Concern
require "bolognese"
require "csv"
Method register_url
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def register_url
if url.blank?
raise ActionController::BadRequest.new,
"[Handle] Error updating DOI " + doi + ": url missing."
end
- Read upRead up
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 register_url
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def register_url
if url.blank?
raise ActionController::BadRequest.new,
"[Handle] Error updating DOI " + doi + ": url missing."
end
Method get_dois
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_dois(options = {})
if options[:prefix].blank?
return OpenStruct.new(
body: { "errors" => [{ "title" => "Prefix missing" }] },
)
Method get_doi
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_doi(options = {})
if options[:doi].blank?
return OpenStruct.new(
body: { "errors" => [{ "title" => "DOI missing" }] },
)
Method delete_doi
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete_doi(options = {})
if options[:doi].blank?
return OpenStruct.new(
body: { "errors" => [{ "title" => "DOI missing" }] },
)
Method parse_attributes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parse_attributes(element, options = {})
content = options[:content] || "__content__"
if element.is_a?(String) && options[:content].nil?
CGI.unescapeHTML(element)
- Read upRead up
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 12 (exceeds 5 allowed). Consider refactoring. Open
def get_dois(options = {})
if options[:prefix].blank?
return OpenStruct.new(
body: { "errors" => [{ "title" => "Prefix missing" }] },
)
- Read upRead up
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 encode_doi
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def encode_doi(prefix, options = {})
return nil if prefix.blank?
number = options[:number].to_s.scan(/\d+/).join("").to_i
shoulder = options[:shoulder].to_s
- Read upRead up
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 match_url_with_domains
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def match_url_with_domains(url: nil, domains: nil)
return false if url.blank? || domains.blank?
return true if domains == "*"
uri = Addressable::URI.parse(url)
- Read upRead up
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 delete_doi
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def delete_doi(options = {})
if options[:doi].blank?
return OpenStruct.new(
body: { "errors" => [{ "title" => "DOI missing" }] },
)
- Read upRead up
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_doi
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_doi(options = {})
if options[:doi].blank?
return OpenStruct.new(
body: { "errors" => [{ "title" => "DOI missing" }] },
)
- Read upRead up
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_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_url
url = "#{ENV['HANDLE_URL']}/api/handles/#{doi}?index=1"
response = Maremma.get(url, ssl_self_signed: true, timeout: 10)
if response.status != 200
- Read upRead up
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"