Method run
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def run
n = opt[:min_blast_hits] < 10 ? 10 : opt[:min_blast_hits]
n = 50 if n > 50
raise NotEnoughHitsError if hits.length < n
- 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 validation_alignment.rb
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'bio'
require 'forwardable'
require 'genevalidator/exceptions'
require 'genevalidator/get_raw_sequences'
Method run
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
n = opt[:min_blast_hits] < 10 ? 10 : opt[:min_blast_hits]
n = 50 if n > 50
raise NotEnoughHitsError if hits.length < n
Method multiple_align_mafft
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def multiple_align_mafft(prediction, hits)
raise unless prediction.is_a?(Query) && hits[0].is_a?(Query)
opt = ['--maxiterate', '1000', '--localpair', '--anysymbol', '--quiet',
'--thread', @num_threads.to_s]
- 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 plot_alignment
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def plot_alignment(freq, ma = @multiple_alignment)
# get indeces of consensus in the multiple alignment
consensus = get_consensus(ma[0..ma.length - 2])
consensus_idxs = consensus.split(//).each_index.select { |j| isalpha(consensus[j]) }
consensus_ranges = array_to_ranges(consensus_idxs)
Method get_sm_pssm
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_sm_pssm(ma, threshold = 0.7)
sm = ''
freq = []
(0..ma[0].length - 1).each do |i|
freqs = Hash.new(0)
- 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 conclude
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def conclude
if @result == :yes
'There is no evidence based on the top 10 BLAST hits to suggest any' \
' problems with the query sequence.'
else
Method initialize
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(short_header, header, description, gaps = 0, extra_seq = 0,
consensus = 1, threshold = 20, expected = :yes)
Method conclude
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def conclude
if @result == :yes
'There is no evidence based on the top 10 BLAST hits to suggest any' \
' problems with the query sequence.'
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"
Further reading
Method remove_isolated_residues
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove_isolated_residues(seq, len = 2)
gap_starts = seq.to_enum(:scan, /(-\w{1,#{len}}-)/i).map { |_m| $`.size + 1 }
# remove isolated residues
gap_starts.each do |i|
(i..i + len - 1).each { |j| seq[j] = '-' if isalpha(seq[j]) }
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def extra_sequence_validation(prediction_raw, sm)
return 1 if prediction_raw.length != sm.length
# find residues that are in the prediction
# but not in the statistical model
no_insertions = 0
- 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 43.
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 gap_validation(prediction_raw, sm)
return 1 if prediction_raw.length != sm.length
# find gaps in the prediction and
# not in the statistical model
no_gaps = 0
- 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 43.
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