Showing 122 of 193 total issues
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',
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'
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'
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"
Further reading
Method create_interaction_claims
has a Cognitive Complexity of 9 (exceeds 5 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|
- 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
gene_claims.sort_by{ |g| [(g.gene_claim_attributes.empty? ? 1 : 0), (GeneClaimPresenter.new(g).publications.empty? ? 1 : 0), (g.gene_claim_aliases.empty? ? 1 : 0), g.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"