lib/cw/read.rb
Method decode_signal
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
Open
def decode_signal
if(@state[FILTERED])
@state[FILTERED] = false
@need_space = true
#dbg_print "wpm #{@wpm.to_s}\nhigh period: #{@high[PERIOD]}\nhigh avg: #{@high[AVG]}"
- 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 Read
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Read
def n ; N ; end
def k ; (0.5 + ((n * @tone / @sample_rate))).to_i ; end
def w ; ((2 * Math::PI) / n) * k ; end
Method initialize
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize(filename)
@tone = TONE
@mag_max = 0
@mag_min = 999999999
@sample_rate = SAMPLE_RATE
Method calc_filtered_state
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
def calc_filtered_state
if real_state_change?
reset_noise_blanker
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 input
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def input
dly = @n_delay_ms
open_sound_device
nval = @n_val
buf = @buf_in
Method decode_signal
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def decode_signal
if(@state[FILTERED])
@state[FILTERED] = false
@need_space = true
#dbg_print "wpm #{@wpm.to_s}\nhigh period: #{@high[PERIOD]}\nhigh avg: #{@high[AVG]}"