Showing 193 of 193 total issues
Method unpack_locals
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def unpack_locals(params)
@preset_fda = (params[:approved_drug] == "checked" ? "Approved" : "")
@preset_neo = (params[:anti_neoplastic] == "checked" ? "Anti-neoplastics" : "")
@preset_immuno = (params[:immunotherapy] == "checked" ? "Immunotherapies" : "")
@preset_clin = (params[:clinically_actionable] == "checked" ? "Clinically Actionable" : "")
- 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
Function parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parse(self):
self.rows = []
go_ids = [':'.join((x['go_id'][:2], x['go_id'][2:])) for x in self.dgidb_go_terms]
category_lookup = {x['go_id']: x['human_readable'].upper() for x in self.dgidb_go_terms}
- 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 create_interaction_claims
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_interaction_claims
CSV.foreach(file_path, :headers => true, :col_sep => "\t") do |row|
next if row['Association'] == 'not associated' || row['Association'] == 'ambiguous'
if row['Entity1_type'] == 'Gene' and row['Entity2_type'] == 'Chemical'
gene_name = row['Entity1_name']
Similar blocks of code found in 2 locations. Consider refactoring. Open
def group_map(drug)
hash = drug_claims.each_with_object({}) do |drug_claim, h|
source_db_name = drug_claim.source.source_db_name
names = drug_claim.drug_claim_aliases.map{|a| a.alias} << drug_claim.name
names.each do |name|
- 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 59.
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
def group_map(gene)
hash = gene_claims.each_with_object({}) do |gene_claim, h|
source_db_name = gene_claim.source.source_db_name
names = gene_claim.gene_claim_aliases.map{|a| a.alias} << gene_claim.name
names.each do |name|
- 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 59.
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 uniquify_gene_claims
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.uniquify_gene_claims
DataModel::GeneClaim.find_each do |gc|
all_matching_claims = DataModel::GeneClaim.where(name: gc.name, nomenclature: gc.nomenclature, source_id: gc.source_id).all
next if all_matching_claims.length == 1
Method import_claims
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_claims
CSV.foreach(file_path, :col_sep => "\t", :headers => true) do |row|
drug_claim = create_drug_claim(row['drug_id'].upcase, row['drug_name'], 'DrugBank Drug Identifier')
create_drug_claim_alias(drug_claim, row['drug_name'].upcase, 'DrugBank Drug Name')
Method sort_value
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.sort_value(sortval)
case sortval
when 'CIViC'
1
when 'DoCM'
Method match_search_terms_to_objects
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.match_search_terms_to_objects(search_terms, scope, filter)
search_terms = search_terms.dup
results_to_gene_groups = search_terms.each_with_object({}) { |term, h| h[term] = [] }
unfiltered_gene_results = DataModel::Gene.send(scope).where(["genes.name in (?) or entrez_id in (?)", search_terms, search_terms.map {|x| Integer(x) rescue nil }.compact])
Method initialize
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
@term_to_matches_dict = {}
@term_to_record_dict = {}
@valid_chembl_ids = []
@invalid_chembl_ids = []
Method uniquify_drug_claims
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.uniquify_drug_claims
DataModel::DrugClaim.find_each do |dc|
all_matching_claims = DataModel::DrugClaim.where(name: dc.name, nomenclature: dc.nomenclature, source_id: dc.source_id).all
next if all_matching_claims.length == 1
Similar blocks of code found in 2 locations. Consider refactoring. Open
drug_name = row['Entity1_name']
pharmgkb_drug_id = row['Entity1_id']
gene_name = row['Entity2_name']
pharmgkb_gene_id = row['Entity2_id']
drug_claim = create_drug_claim(drug_name, drug_name, 'PharmGKB Drug Name')
- 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 58.
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
gene_name = row['Entity1_name']
pharmgkb_gene_id = row['Entity1_id']
drug_name = row['Entity2_name']
pharmgkb_drug_id = row['Entity2_id']
drug_claim = create_drug_claim(drug_name, drug_name, 'PharmGKB Drug Name')
- 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 58.
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
Consider simplifying this complex logical expression. Open
elsif val == 'inhibitory immune response' || val == 'car-t-cell-therapy(dual specific)' || val == 'immunomodulator' || val == 'immunomodulator (immunostimulant)' || val == 'immune response agent' || val == 'car-t-cell-therapy' || val == 'immune response agent' || val == 'immunostimulant'
'immunotherapy'
elsif val == 'component of'
'product of'
elsif val == 'opener'
Function cookie
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var config = $.cookie = function (key, value, options) {
// write
if (value !== undefined) {
options = $.extend({}, config.defaults, options);
Method uniquify_interaction_claims
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.uniquify_interaction_claims
DataModel::InteractionClaim.find_each do |ic|
all_matching_claims = DataModel::InteractionClaim.where(drug_claim_id: ic.drug_claim_id, gene_claim_id: ic.gene_claim_id, source_id: ic.source_id).all
next if all_matching_claims.length == 1
Method validate_interaction_request
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate_interaction_request(params)
if params[:search_mode].nil?
if params[:genes]
params[:search_mode] = 'genes'
elsif params[:drugs]
- 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 a Cognitive Complexity of 11 (exceeds 5 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
- 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_search_terms_to_objects
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.match_search_terms_to_objects(search_terms, scope, filter)
search_terms = search_terms.dup
results_to_gene_groups = search_terms.each_with_object({}) { |term, h| h[term] = [] }
unfiltered_gene_results = DataModel::Gene.send(scope).where(["genes.name in (?) or entrez_id in (?)", search_terms, search_terms.map {|x| Integer(x) rescue nil }.compact])
- 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 trust_level_map
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.trust_level_map
{
'Expert curated' =>
[
'MyCancerGenome',