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 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 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'
Method clipping_check
has a Cognitive Complexity of 9 (exceeds 5 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' ||
- 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 audio_tool_segment
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def audio_tool_segment(extension, audio_tool_method, source, source_info, target, modify_parameters)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(audio_defaults, logger, temp_dir, run_program, opts = {})
Method modify_wavpack
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def modify_wavpack(source, source_info, target, start_offset, end_offset)
Method from_executables
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.from_executables(audio_defaults, logger, temp_dir, timeout_sec, opts = {})
Method modify_mp3splt
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def modify_mp3splt(source, source_info, target, start_offset, end_offset)
Method info
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def info(source)
fail Exceptions::FileNotFoundError, "Source does not exist: #{source}" unless File.exists? source
fail Exceptions::FileEmptyError, "Source exists, but has no content: #{source}" if File.size(source) < 1
if File.extname(source) == '.wac'
- 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"