Showing 193 of 193 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
drug_claim = create_drug_claim(individual_drug_name, individual_drug_name, 'CGI Drug Name')
if row['Gene'].include?(';')
row['Gene'].split(';').each do |indv_gene|
gene_claim = create_gene_claim(indv_gene, 'CGI Gene Name')
interaction_claim = create_interaction_claim(gene_claim, drug_claim)
- 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 102.
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
drug_claim = create_drug_claim(individual_drug_name, individual_drug_name, 'CGI Drug Name')
if row['Gene'].include?(';')
row['Gene'].split(';').each do |indv_gene|
gene_claim = create_gene_claim(indv_gene, 'CGI Gene Name')
interaction_claim = create_interaction_claim(gene_claim, drug_claim)
- 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 102.
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
Function write
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def write(self):
print('Writing to .tsv...')
i = 0
no_ensembl = no_entrez = total = 0
header = ('count', 'drug_id', 'drug_name', 'drug_synonyms', 'drug_cas_number', 'drug_brands',
- 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 to_tsv
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def to_tsv
# entrez = Genome::Updaters::GetEntrez.new
# f = open(entrez.local_path('gene_info.gz'))
check_files
f = File.open(local_path('gene_info.gz'))
- 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
Consider simplifying this complex logical expression. Open
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'
'inhibitor'
elsif val == 'channel blocker' || val == 'blocker (channel blocker)' || val == 'nucleotide exchange blocker'
'blocker'
elsif val == 'antisense' || val == 'sirna drug'
Method create_interaction_claims
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def create_interaction_claims
CSV.foreach(file_path, :headers => true) do |row|
drug_id = row['compound_id']
drug_name = row['compound_name']
gene_name = row['gene_names']
- 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 run
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(source_id: nil)
claims = DataModel::DrugClaim.eager_load(:drug_claim_aliases, :drug_claim_attributes).where(drug_id: nil)
unless source_id.nil?
claims = claims.where(source_id: source_id)
end
Method import_claims
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_claims
CSV.foreach(gene_file_path, :headers => true) do |line|
gene_name = line['Human Entrez Gene']
next if blank?(gene_name)
Class GeneCategorySearchResultsPresenter
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class GeneCategorySearchResultsPresenter
include Genome::Extensions
attr_reader :search_results
def initialize(search_results, params, start_time, view_context)
Function fnUpdate
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
"fnUpdate": function ( oSettings, fnDraw ) {
var iListLength = 5;
var oPaging = oSettings.oInstance.fnPagingInfo();
var an = oSettings.aanFeatures.p;
var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
- 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 interaction_search_results
has a Cognitive Complexity of 17 (exceeds 5 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]
- 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 17 (exceeds 5 allowed). Consider refactoring. Open
def parse(self):
self.rows = []
with open(os.path.join(self.download_path, 'gene_info.human')) as f:
fieldnames = ['tax_id', 'entrez_id', 'entrez_gene_symbol', 'locus_tag',
'entrez_gene_synonyms', 'dbXrefs', 'chromosome', 'map_loc',
- 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
File get_drugbank.py
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
__author__ = 'Kelsy C Cotto'
import zipfile
import os
import sys
Class InteractionSearchResultApiV1Presenter
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class InteractionSearchResultApiV1Presenter
def initialize(search_result, identifier, interactions)
@result = search_result
@identifier = identifier
@interactions = interactions.flat_map(&:interaction_claims).map{|i| InteractionWrapper.new(i)}
Similar blocks of code found in 2 locations. Consider refactoring. Open
class UpdateCgi < TsvUpdater
def tempfile_name
['cgi_biomarkers_per_variant', '.tsv']
end
- 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 81.
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
class UpdatePharmgkb < TsvUpdater
def tempfile_name
['pharmgkb_interactions', '.tsv']
end
- 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 81.
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 dgidb_go_terms
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dgidb_go_terms
@dgidb_go_terms ||= [{short_name: "Kinase", full_go_name: "KinaseActivity",
human_readable: "Kinase", go_id: "GO0016301"},
{short_name: "TyrosineKinase", full_go_name: "ProteinTyrosineKinaseActivity",
human_readable: "Tyrosine Kinase", go_id: "GO0004713"},
Consider simplifying this complex logical expression. Open
elsif val =~ /other/ || val =~ /unknown/ || val == 'protector' || val == 'oxidizer' || val == 'coating agent' || val == 'dilator' || val == 'deoxidizer' || val == 'diffusing substance'|| val == 'vesicant' || val == 'gene replacement'
'other/unknown'
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)'
Function truncate
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function truncate() {
var data = this.data('trunk8'),
settings = data.settings,
width = settings.width,
side = settings.side,
Method get_normalized_record_for_chembl_match
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def get_normalized_record_for_chembl_match(chembl_match)
records = chembl_match['records']
if records.size == 1
return get_normalized_record_or_drug_for_chembl_id(records.first['concept_identifier'])
else
- 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"