Showing 257 of 257 total issues
Method index
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def index
page = paging_params[:page].blank? ? 1 : paging_params[:page].to_i
order_by = paging_params[:order_by].blank? ? :id : paging_params[:order_by].to_s.to_sym
order_dir = paging_params[:order_dir].blank? ? :desc : paging_params[:order_dir].to_s.to_sym
- 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 directory_list
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def directory_list(path, items, offset, max_items)
children = []
# Note: added a sort here for stable sorting. We're pivoting away from having thousands of files in folders
# so hopefully we can take (the massive) penalty hit of evaluating the entire directory listing each time
- 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 filtered_routes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def filtered_routes
collect_routes { |route|
next if route.internal?
next if route.engine?
next if route.verb.blank?
- 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 clear
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def clear(range_start = nil, range_end = nil, status: nil)
raise ArgumentError, "#{status} is not a valid status" unless status.nil? || STATUSES.include?(status)
get_status_ids(range_start, range_end).count do |job_id|
# no status filtering
- 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 update
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
do_get_opts
if @is_system_job
raise CustomErrors::MethodNotAllowedError.new(
Method schema
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.schema
{
type: 'object',
additionalProperties: false,
properties: {
Method annotation_download
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def annotation_download
selected_params = annotation_download_params
selected_project_id = selected_params[:selected_project_id]
selected_site_id = selected_params[:selected_site_id]
Method compare_csv_db
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def compare_csv_db(csv_file)
original_audio = BawWorkers::Config.original_audio_helper
# gather all existing files
files = []
Method perform
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(analysis_params)
analysis_params_sym = BawWorkers::Jobs::Analysis::Payload.normalize_opts(analysis_params)
BawWorkers::Config.logger_worker.info do
{ message: 'Started analysis', parameters: Job.format_params_for_log(analysis_params_sym) }
Method info
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def info(source)
source = source.to_s
raise ArgumentError, "Source is not a wac file: #{source}" unless source.match(/\.wac$/)
raise Exceptions::AudioFileNotFoundError, "Could not find #{source}." unless File.exist?(source)
Method create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create
do_new_resource
do_set_attributes(tagging_params)
get_audio_recording
get_audio_event
- 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 filter_settings
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.filter_settings
{
valid_fields: [:id, :text, :data, :created_at, :creator_id, :updated_at, :updater_id, :study_ids],
render_fields: [:id, :text, :data, :created_at, :creator_id, :updated_at, :updater_id],
new_spec_fields: lambda { |_user|
Method show_results
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show_results(is_head_request, analysis_job_item, results_path, api_opts)
# assertion: audio_recordings must be in the specified job - authorization should filter out those that aren't
# extract parameters for analysis response
audio_recording = analysis_job_item.audio_recording
Method filter_settings
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.filter_settings
{
valid_fields: [:id, :dataset_id, :name, :created_at, :creator_id, :updated_at, :updater_id],
render_fields: [:id, :dataset_id, :name, :created_at, :creator_id, :updated_at, :updater_id],
new_spec_fields: lambda { |_user|
Method create
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
#do_new_resource - custom new audio_recording
#do_set_attributes(audio_recording_params) - custom set attributes
@audio_recording = AudioRecording.build_by_file_hash(audio_recording_params)
get_project_site
Method update_status_params_check
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_status_params_check
opts = { error_info: { audio_recording_id: params[:id] } }
if @audio_recording.blank?
respond_error(
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
# http://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide
Method project_access_request
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def project_access_request(sender_user, project_ids, reason)
@sender_user = sender_user
@access_reason = reason
user_projects = {}
Method filter_settings
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.filter_settings
{
valid_fields: [:id, :project_id, :user_id, :level, :allow_anonymous, :allow_logged_in, :creator_id, :created_at],
render_fields: [:id, :project_id, :user_id, :level, :allow_anonymous, :allow_logged_in, :updated_at, :updater_id,
:created_at, :creator_id],