Showing 39 of 39 total issues
Method rescue_symbol
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def rescue_symbol(symbol, method = @rescue_method, rehearsal = false)
return @rescue_history[symbol] if @rescue_history[symbol]
case method
when :auto
- 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 parse
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def parse(fin)
# Headline
names = fin.gets.chomp.split("\t")
index2identifier = {}
index_hgncid = nil
- 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 load
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def self.load(
path = nil,
prefix: '',
colname: {
source: 'Source',
- 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
Class Table
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Table
# Version
VERSION = '0.6.1'.freeze
# Primary key
File table.rb
has 311 lines of code (exceeds 250 allowed). Consider refactoring. Open
module BioTCM
# One of the basic data models used in BioTCM to process
# {https://github.com/biotcm/biotcm/wiki/Formats#tab .tab files},
# developed under <b>"strict entry and tolerant exit"</b> philosophy.
#
Method get_pathway
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.get_pathway(pathway_id)
raise ArgumentError, 'Invalid pathway_id' unless (pathway_id = validate_pathway_id(pathway_id))
file_path = BioTCM.path_to("kegg/#{pathway_id}.xml")
unless File.exist?(file_path)
- 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 get_pathway
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_pathway(pathway_id)
raise ArgumentError, 'Invalid pathway_id' unless (pathway_id = validate_pathway_id(pathway_id))
file_path = BioTCM.path_to("kegg/#{pathway_id}.xml")
unless File.exist?(file_path)
Method parse
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse(fin)
# Headline
names = fin.gets.chomp.split("\t")
index2identifier = {}
index_hgncid = nil
Method set_row
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def set_row(row, val)
# Setter
if !row.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array))
raise ArgumentError, 'Illegal argument type'
elsif val.is_a?(Array) && val.size != col_keys.size
- 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_col
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def set_col(col, val)
if !col.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array))
raise ArgumentError, 'Illegal argument type'
elsif val.is_a?(Array) && val.size != row_keys.size
raise ArgumentError, 'Row size not match'
- 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 load
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.load(
path = nil,
prefix: '',
colname: {
source: 'Source',
Method extended
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.extended(mod)
mod.instance_eval do
# Initialize instance variables
@rescue_symbol = true
@rescue_method = :auto
- 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 rescue_symbol
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def rescue_symbol(symbol, method = @rescue_method, rehearsal = false)
return @rescue_history[symbol] if @rescue_history[symbol]
case method
when :auto
Method merge
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def merge(tab)
raise ArgumentError, 'Only tables could be merged' unless tab.is_a?(self.class)
raise ArgumentError, 'Primary keys not the same' unless tab.primary_key == primary_key
# Empty content
Method to_table
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def to_table(seperator: "\t")
stuff = split(/\r\n|\n/)
# Comments
comments = []
- 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 extended
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.extended(mod)
mod.instance_eval do
# Initialize instance variables
@rescue_symbol = true
@rescue_method = :auto
Method extract_by_species
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def extract_by_species(filepath, species = 'Homo sapiens')
fout = File.new(filepath, 'w')
raise ArgumentError, 'Illegal filepath given' unless fout
species = find_species_id(species).to_i
- 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 mine_offline
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def mine_offline(query)
@gene_detector = BioTCM::Apps::GeneDetector.new
datapath = BioTCM.path_to("tmp/PubmedGeneMiner.#{BioTCM.stamp}.txt")
as_medline(query).download_abstracts(datapath)
- 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_table
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_table(seperator: "\t")
stuff = split(/\r\n|\n/)
# Comments
comments = []
Similar blocks of code found in 2 locations. Consider refactoring. Open
File.open('ppi.v10.homo.sapiens.700.txt', 'w') do |fout|
File.open('protein.links.detailed.v10.homo.sapiens.txt').each do |line|
col = line.chomp.split("\t")
next unless (col[0] = protein2symbol[col[0]]) && (col[1] = protein2symbol[col[1]])
next unless col.last.to_i >= 700
- 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 51.
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