File event.rb
has 878 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Event < ApplicationRecord
# include helper module for query caching
include Cacheable
# include event processing
Class Event
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
class Event < ApplicationRecord
# include helper module for query caching
include Cacheable
# include event processing
Method import_doi
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.import_doi(id, options = {})
doi_id = validate_doi(id)
return nil if doi_id.blank?
# check whether DOI has been stored with DataCite already
- 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 query_aggregations
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.query_aggregations
{
sources: { terms: { field: "source_id", size: 10, min_doc_count: 1 } },
prefixes: { terms: { field: "prefix", size: 10, min_doc_count: 1 } },
occurred: {
Method import_doi
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_doi(id, options = {})
doi_id = validate_doi(id)
return nil if doi_id.blank?
# check whether DOI has been stored with DataCite already
Method import_by_id
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_by_id(options = {})
return nil if options[:id].blank?
id = options[:id].to_i
index =
Method set_source_and_target_doi
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_source_and_target_doi
return nil unless subj_id && obj_id
case relation_type_id
when *REFERENCE_RELATION_TYPES
Method as_indexed_json
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def as_indexed_json(_options = {})
{
"uuid" => uuid,
"subj_id" => subj_id,
"obj_id" => obj_id,
Method update_registrant
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.update_registrant(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || [])
# ra = options[:ra] || "crossref"
source_id = options[:source_id] || "datacite-crossref,crossref"
Method subj_id_check
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.subj_id_check(options = {})
size = (options[:size] || 1_000).to_i
cursor = [options[:from_id], options[:until_id]]
response =
Method update_datacite_orcid_auto_update
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.update_datacite_orcid_auto_update(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || []).to_i
response =
Method update_datacite_ra
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.update_datacite_ra(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || [])
ra = options[:ra] || "crossref"
source_id = "datacite-#{ra}"
Method import_by_id
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.import_by_id(options = {})
return nil if options[:id].blank?
id = options[:id].to_i
index =
- 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 update_crossref
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.update_crossref(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || [])
response =
Method subj_id_check
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.subj_id_check(options = {})
size = (options[:size] || 1_000).to_i
cursor = [options[:from_id], options[:until_id]]
response =
- 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 loop_through_events
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.loop_through_events(options)
size = (options[:size] || 1_000).to_i
cursor = options[:cursor] || []
filter = options[:filter] || {}
label = options[:label] || ""
- 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 update_crossref
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.update_crossref(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || [])
response =
- 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 modify_nested_objects
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Wontfix
def self.modify_nested_objects(options = {})
size = (options[:size] || 1_000).to_i
cursor = [options[:from_id], options[:until_id]]
response = Event.query(nil, page: { size: 1, cursor: [] })
- 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 update_registrant
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.update_registrant(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || [])
# ra = options[:ra] || "crossref"
source_id = options[:source_id] || "datacite-crossref,crossref"
- 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 update_datacite_orcid_auto_update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.update_datacite_orcid_auto_update(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || []).to_i
response =
- 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 update_datacite_ra
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.update_datacite_ra(options = {})
size = (options[:size] || 1_000).to_i
cursor = (options[:cursor] || [])
ra = options[:ra] || "crossref"
source_id = "datacite-#{ra}"
- 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 dois_to_import
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def dois_to_import
[doi_from_url(subj_id), doi_from_url(obj_id)].compact.reduce(
[],
) do |sum, d|
prefix = d.split("/", 2).first
- 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 set_defaults
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_defaults
self.uuid = SecureRandom.uuid if uuid.blank?
self.subj_id = normalize_doi(subj_id) || subj_id
self.obj_id = normalize_doi(obj_id) || obj_id
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
Event.where(id: id..(id + 499)).find_in_batches(
batch_size: 500,
) do |events|
response =
Event.__elasticsearch__.client.bulk index: index,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 84.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
indexes :subj,
type: :object,
properties: {
type: { type: :keyword },
id: { type: :keyword },
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 39.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
indexes :obj,
type: :object,
properties: {
type: { type: :keyword },
id: { type: :keyword },
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 39.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
relation_types: {
terms: { field: "relation_type_id", size: 10, min_doc_count: 1 },
aggs: {
year_month: {
date_histogram: {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 35.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
citation_types: {
terms: { field: "citation_type", size: 10, min_doc_count: 1 },
aggs: {
year_month: {
date_histogram: {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 35.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
registrants: {
terms: { field: "registrant_id", size: 10, min_doc_count: 1 },
aggs: {
year: {
date_histogram: {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 35.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76