Showing 51 of 57 total issues
Method modify
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def modify(source, target, modify_parameters = {})
fail ArgumentError, "Target is not a png file: : #{target}" unless target.match(/\.png/)
fail ArgumentError, "Source is not a wav file: : #{source}" unless source.match(/\.wav/)
fail Exceptions::FileNotFoundError, "Source does not exist: #{source}" unless File.exists? source
fail Exceptions::FileAlreadyExistsError, "Target exists: #{target}" if File.exists? target
- 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 audio_base.rb
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
module BawAudioTools
class AudioBase
attr_reader :audio_defaults, :logger, :temp_dir, :timeout_sec,
:audio_ffmpeg, :audio_mp3splt, :audio_sox,
Method modify_worker
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def modify_worker(source_info, source, target, modify_parameters = {})
if source_info[:media_type] == 'audio/wavpack'
# convert to wave and segment
audio_tool_segment('wav', :modify_wavpack, source, source_info, target, modify_parameters)
elsif source_info[:media_type] == 'audio/x-waac'
- 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 AudioBase
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class AudioBase
attr_reader :audio_defaults, :logger, :temp_dir, :timeout_sec,
:audio_ffmpeg, :audio_mp3splt, :audio_sox,
:audio_wavpack, :audio_shntool, :audio_wav2png,
Method check_integrity_output
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def check_integrity_output(execute_msg)
#stdout = execute_msg[:stdout]
stderr = execute_msg[:stderr]
result = {
- 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 audio_ffmpeg.rb
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
module BawAudioTools
class AudioFfmpeg
ERROR_FRAME_SIZE_1 = "Could not find codec parameters for stream [0-9]+ \\(Audio\\: [a-zA-Z0-9]+\\, [0-9]+ channels\\, [a-zA-Z0-9]+\\)\\: unspecified frame size"
ERROR_FRAME_SIZE_2 = "Failed to read frame size: Could not seek to [0-9]+\\."
Method execute
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute(command, raise_exit_error = true)
if OS.windows?
#if command.include? '&& move'
# if windows and contains a 'move' command, need to ensure relative path has '\' separators
Method modify
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modify(source, target, modify_parameters = {})
fail ArgumentError, "Target is not a png file: : #{target}" unless target.match(/\.png/)
fail ArgumentError, "Source is not a wav file: : #{source}" unless source.match(/\.wav/)
fail Exceptions::FileNotFoundError, "Source does not exist: #{source}" unless File.exists? source
fail Exceptions::FileAlreadyExistsError, "Target exists: #{target}" if File.exists? target
Method check_integrity_output
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_integrity_output(execute_msg)
#stdout = execute_msg[:stdout]
stderr = execute_msg[:stderr]
result = {
Method read_to_stream
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def read_to_stream(stdout, stderr, output, error, options)
tick = options[:tick]
buffer_size = options[:buffer_size]
exceptions = []
is_windows = OS.windows?
- 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 modify_command
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def modify_command(source, source_info, target, start_offset = nil, end_offset = nil, channel = nil, sample_rate = nil)
fail Exceptions::FileNotFoundError, "Source does not exist: #{source}" unless File.exists? source
fail Exceptions::FileAlreadyExistsError, "Target exists: #{target}" if File.exists? target
fail ArgumentError, "Source and Target are the same file: #{target}" if source == target
- 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 info
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def info(source)
fail ArgumentError, "Source is not a wac file: #{source}" unless source.match(/\.wac$/)
fail Exceptions::AudioFileNotFoundError, "Could not find #{source}." unless File.exist?(source)
# WAac header format:
Method clipping_check
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clipping_check(source, info_flattened)
# check for clipping, zero signal
# only if duration less than 4 minutes
four_minutes_in_sec = 4.0 * 60.0
if (info_flattened[:media_type] == 'audio/wav' ||
Method codec_calc
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def codec_calc(target)
# high quality codec settings
# https://trac.ffmpeg.org/wiki/GuidelinesHighQualityAudio
Method modify_command
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def modify_command(source, source_info, target, start_offset = nil, end_offset = nil)
fail ArgumentError, "Source is not a wavpack file: #{source}" unless source.match(/\.wv$/)
fail ArgumentError, "Target is not a wav file: : #{target}" unless target.match(/\.wav$/)
fail Exceptions::FileNotFoundError, "Source does not exist: #{source}" unless File.exists? source
fail Exceptions::FileAlreadyExistsError, "Target exists: #{target}" if File.exists? target
- 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 command
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def command(source, source_info, target,
width = 1800, height = 280,
colour_bg = 'efefefff', colour_fg = '00000000',
scale = :linear,
db_min = -48, db_max = 0)
Method spectrogram_command
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def spectrogram_command(source, source_info, target, start_offset = nil, end_offset = nil, channel = nil, sample_rate = nil,
window = nil, window_function = nil, colour = nil)
Method execute
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def execute(command, raise_exit_error = true)
if OS.windows?
#if command.include? '&& move'
# if windows and contains a 'move' command, need to ensure relative path has '\' separators
- 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 check_sample_rate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def check_sample_rate(target, modify_parameters = {}, source_info = {})
if modify_parameters.include?(:sample_rate)
sample_rate = modify_parameters[:sample_rate].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 modify_worker
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modify_worker(source_info, source, target, modify_parameters = {})
if source_info[:media_type] == 'audio/wavpack'
# convert to wave and segment
audio_tool_segment('wav', :modify_wavpack, source, source_info, target, modify_parameters)
elsif source_info[:media_type] == 'audio/x-waac'