QutBioacoustics/baw-server

View on GitHub

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

Severity: Minor
Found in app/controllers/admin/audio_recordings_controller.rb - About 1 hr to fix

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
Severity: Minor
Found in app/modules/file_systems/physical.rb - About 1 hr to fix

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?
Severity: Minor
Found in app/modules/api/custom_routes.rb - About 1 hr to fix

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

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(
Severity: Minor
Found in app/controllers/analysis_jobs_items_controller.rb - About 1 hr to fix

    Method schema has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.schema
        {
          type: 'object',
          additionalProperties: false,
          properties: {
    Severity: Minor
    Found in app/models/project.rb - About 1 hr to fix

      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]
      Severity: Minor
      Found in app/controllers/public_controller.rb - About 1 hr to fix

        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 = []
        Severity: Minor
        Found in lib/gems/baw-workers/lib/baw_workers/jobs/audio_check/csv_helper.rb - About 1 hr to fix

          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) }
          Severity: Minor
          Found in lib/gems/baw-workers/lib/baw_workers/jobs/analysis/job.rb - About 1 hr to fix

            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)
            
            
            Severity: Minor
            Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_wac2wav.rb - About 1 hr to fix

              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
              Severity: Minor
              Found in app/controllers/taggings_controller.rb - About 1 hr to fix

              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|
              Severity: Minor
              Found in app/models/question.rb - About 1 hr to fix

                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
                Severity: Minor
                Found in app/controllers/analysis_jobs_results_controller.rb - About 1 hr to fix

                  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|
                  Severity: Minor
                  Found in app/models/study.rb - About 1 hr to fix

                    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
                    Severity: Minor
                    Found in app/controllers/audio_recordings_controller.rb - About 1 hr to fix

                      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(
                      Severity: Minor
                      Found in app/controllers/audio_recordings_controller.rb - About 1 hr to fix

                        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' ||
                        Severity: Minor
                        Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 1 hr to fix

                          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
                          Severity: Minor
                          Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 1 hr to fix

                            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 = {}
                            Severity: Minor
                            Found in app/mailers/project_mailer.rb - About 1 hr to fix

                              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],
                              Severity: Minor
                              Found in app/models/permission.rb - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language