File audio_base.rb
has 310 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,
:audio_wavpack, :audio_shntool, :audio_waveform,
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 25 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_waveform,
:audio_wac2wav
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 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 check_sample_rate
has a Cognitive Complexity of 10 (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
# source_info sample_rate_hertz should match modify_parameters original_sample_rate if both are supplied
- 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 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 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_wavpack
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def modify_wavpack(source, source_info, target, start_offset, end_offset)
Method modify_mp3splt
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def modify_mp3splt(source, source_info, target, start_offset, end_offset)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(audio_defaults, logger, temp_dir, run_program, opts = {})
Method check_source
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_source(path)
raise Exceptions::FileNotFoundError, 'Source path was empty or nil' if path.nil? || (path.is_a?(String) && path.empty?)
path = Pathname(path)
# Maybe worth resolving symlinks to a realpath, but currently does not cause any failures without
- 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"