Showing 193 of 193 total issues
Method interaction_search_results
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def interaction_search_results
if !params[:name].nil?
params[:search_mode] = 'drugs'
params[:identifiers] = params[:name]
params[:gene_categories] = DataModel::GeneClaimCategory.all_category_names unless params[:gene_categories]
Method run
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.run(tsv_path)
blank_filter = ->(x) { x.blank? || x == "''" || x == '""' }
upcase = ->(x) {x.upcase}
downcase = ->(x) {x.downcase}
known = ->() {if :action_type.blank?
Method create_interaction_claims
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_interaction_claims
api_client = ApiClient.new
genes = get_genes(api_client)
drugs = get_drugs(api_client)
api_client.variants.each do |variant|
Method categories
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def categories
{
"KINASE" => "0016301",
"TYROSINE KINASE" => "0004713",
"SERINE THREONINE KINASE" => "0004674",
Method run
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.run(tsv_path)
na_filter = ->(x) { x.upcase == 'N/A' }
TSVImporter.import tsv_path, PharmgkbRow, source_info do
interaction known_action_type: 'unknown' do
attribute 'Interaction Type', name: 'n/a'
Identical blocks of code found in 2 locations. Consider refactoring. Open
def update(self):
if not self.is_current():
self.download_files()
self.parse()
self.write()
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
def update(self):
if not self.is_current():
self.download_files()
self.parse()
self.write()
- 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
Method process_pubchem_file
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process_pubchem_file(pubchem_file)
alternate_names = []
current_id = nil
lines_processed = 0
Zlib::GzipReader.new(pubchem_file).each_line do |line|
- 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 add_drug_claim_attributes_to_drug
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_drug_claim_attributes_to_drug(drug_claim, drug)
drug_attributes = drug.drug_attributes.pluck(:name, :value)
.map { |drug_attribute| drug_attribute.map(&:upcase) }
.to_set
drug_claim.drug_claim_attributes.each do |drug_claim_attribute|
- 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 add_member
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.add_member(interaction_claim)
drug = interaction_claim.drug_claim.drug
gene = interaction_claim.gene_claim.gene
interaction = DataModel::Interaction.where(drug_id: drug.id, gene_id: gene.id).first_or_create
interaction_claim.interaction = interaction
Method ambiguous_matches
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ambiguous_matches
unless @ambiguous_matches
@ambiguous_matches = []
results = ambiguous_result_presenters.uniq{|r| r.gene_categories}
results.each do |result|
Method match_objects_to_drugs
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.match_objects_to_drugs(unfiltered_results, filtered_results, search_terms)
results_to_drug_groups = search_terms.each_with_object({}) { |term, h| h[term] = [] }
ids_to_results = filtered_results.each_with_object({}) { |result, h| h[result.id] = result}
unfiltered_results.each do |unfiltered_result|
result = ids_to_results[unfiltered_result.id]
Method create_interaction_claims
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_interaction_claims
api_client = ApiClient.new
api_client.genes.each do |gene|
gene_claim = create_gene_claim(gene['geneName'], 'CKB Gene Name')
create_gene_claim_aliases(gene_claim, gene)
Method create_gene_claims
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_gene_claims
api_client = ApiClient.new
categories.each do |category|
start = 0
count = 100
Method add_drug_claim_attributes_to_drug
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_drug_claim_attributes_to_drug(drug_claim, drug)
drug_attributes = drug.drug_attributes.pluck(:name, :value)
.map { |drug_attribute| drug_attribute.map(&:upcase) }
.to_set
drug_claim.drug_claim_attributes.each do |drug_claim_attribute|
Consider simplifying this complex logical expression. Open
elsif val == 'neutralizer' || val == 'reducer' || val == 'metabolizer' || val == 'acetylation' || val == 'chelator' || val == 'cross-linking/alkylation' || val == 'regulator'
'modulator'
elsif val == 'positive allosteric modulator' || val == 'regulator (upregulator)' || val == 'enhancer' || val == 'modulator (allosteric modulator)'
'positive modulator'
elsif val == 'inhibitor, competitive' || val == 'gating inhibitor' || val == 'inhibitor; antagonist; blocker' || val == 'inhibitor (gating inhibitor)' || val == 'growth_inhibition' || val == 'inhibition' || val == 'weak inhibitor' || val == 'aggregation inhibitor' || val == 'inhibition of synthesis' || val == "translocation inhibitor" || val == 'inhibits downstream inflammation cascades' || val == 'inactivator'
Similar blocks of code found in 2 locations. Consider refactoring. Open
DataModel::GeneAttribute.where("name LIKE ' %' or name LIKE '% '").all.each do |a|
clean_attribute = DataModel::GeneAttribute.where(name: a.name.strip, value: a.value.strip, gene_id: a.gene_id).first_or_create
a.sources.each do |source|
clean_attribute.sources << source unless clean_attribute.sources.include? source
a.sources.delete(source)
- 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 47.
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
DataModel::GeneAttribute.where("value LIKE ' %' or value LIKE '% '").all.each do |a|
clean_attribute = DataModel::GeneAttribute.where(name: a.name.strip, value: a.value.strip, gene_id: a.gene_id).first_or_create
a.sources.each do |source|
clean_attribute.sources << source unless clean_attribute.sources.include? source
a.sources.delete(source)
- 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 47.
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
Method partition
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def partition
if has_results?
if is_ambiguous? && has_interactions?
:ambiguous
elsif is_ambiguous? && !has_interactions?
- 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 sorted_claims
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def sorted_claims
drug_claims.sort_by{ |d| [(d.drug_claim_attributes.empty? ? 1 : 0), (DrugClaimPresenter.new(d).publications.empty? ? 1 : 0), (d.drug_claim_aliases.empty? ? 1 : 0), d.sort_value] }
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"