QutBioacoustics/baw-server

View on GitHub

Showing 213 of 257 total issues

Method validate_array_items has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_array_items(value)
      # must be a collection of items
      if !value.respond_to?(:each) || !value.respond_to?(:all?) || !value.respond_to?(:any?) || !value.respond_to?(:count)
        raise CustomErrors::FilterArgumentError, "Must be a collection of items, got #{value.class}."
      end
Severity: Minor
Found in app/modules/filter/validate.rb - About 2 hrs 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 write_audio_recordings_csv has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def write_audio_recordings_csv(original_csv, hash_csv, result_csv)
            audio_info = {}

            BawWorkers::ReadCsv.read_audio_recording_csv(original_csv) do |audio_params|
              audio_info[audio_params[:uuid]] = audio_params
Severity: Major
Found in lib/gems/baw-workers/lib/baw_workers/jobs/audio_check/csv_helper.rb - About 2 hrs to fix

    Method execute has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def execute(prepared_opts, opts)
              BawWorkers::Validation.check_custom_hash(prepared_opts,
                                                       BawWorkers::Jobs::Analysis::Payload::COMMAND_PLACEHOLDERS)
              BawWorkers::Validation.check_custom_hash(opts, BawWorkers::Jobs::Analysis::Payload::OPTS_FIELDS)
              BawWorkers::Jobs::Analysis::Runner.check_command_format(opts)
    Severity: Minor
    Found in lib/gems/baw-workers/lib/baw_workers/jobs/analysis/runner.rb - About 2 hrs to fix

      Method validate_filter_settings has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def validate_filter_settings(value)
            validate_hash(value)
      
            # Common filter settings
      
      
      Severity: Minor
      Found in app/modules/filter/validate.rb - About 1 hr to fix

        Method index has a Cognitive Complexity of 15 (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? ? :text : paging_params[:order_by].to_s.to_sym
              order_dir = paging_params[:order_dir].blank? ? :asc : paging_params[:order_dir].to_s.to_sym
        
        
        Severity: Minor
        Found in app/controllers/admin/tags_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 extract_key has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def extract_key(hash)
                key = nil
                values = []
        
                keys.each do |target|
        Severity: Minor
        Found in app/modules/api/audio_event_parser/key_transformer.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 index has a Cognitive Complexity of 15 (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? ? :group_identifier : paging_params[:order_by].to_s.to_sym
              order_dir = paging_params[:order_dir].blank? ? :asc : paging_params[:order_dir].to_s.to_sym
        
        
        Severity: Minor
        Found in app/controllers/admin/tag_groups_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 show has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def show
            error_code_or_id = params[:name]
        
            status_symbol = :bad_request
            detail_message = 'There was a problem with your request. Perhaps go back and try again?'
        Severity: Minor
        Found in app/controllers/errors_controller.rb - About 1 hr to fix

          Method filter_settings has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.filter_settings
              {
                valid_fields: [
                  :id, :name, :description, :created_at, :creator_id, :updated_at, :updater_id
                ],
          Severity: Minor
          Found in app/models/dataset.rb - About 1 hr to fix

            Method check_integrity_output has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def check_integrity_output(execute_msg)
                  #stdout = execute_msg[:stdout]
                  stderr = execute_msg[:stderr]
            
                  result = {
            Severity: Minor
            Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 1 hr to fix

              Method validate_sorting has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_sorting(order_by, valid_fields, direction)
                    if !order_by.blank? && !direction.blank?
                      # allow both to be nil, but if one is nil and the other is not, that is an error.
                      raise CustomErrors::FilterArgumentError, 'Order by must not be null' if order_by.blank?
                      raise CustomErrors::FilterArgumentError, 'Direction must not be null' if direction.blank?
              Severity: Minor
              Found in app/modules/filter/validate.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 initialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def initialize(user)
                  # ======== Reset Actions ========
              
                  # clear all aliased actions - these mappings are removed:
                  #   alias_action :index, :show, :to => :read
              Severity: Minor
              Found in app/models/ability.rb - About 1 hr to fix

                Method modify has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def modify(source, target, modify_parameters = {})
                      source = Pathname(source)
                      target = Pathname(target)
                      raise ArgumentError, "Source is not a wav file: : #{source}" unless source.extname == '.wav'
                      raise ArgumentError, "Target is not a png file: : #{target}" unless target.extname == '.png'
                Severity: Minor
                Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/spectrogram.rb - About 1 hr to fix

                  Method filter_settings has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.filter_settings
                      common_fields = [:id, :name, :description, :notes, :creator_id, :created_at, :updater_id, :updated_at, :deleter_id,
                                       :deleted_at, :project_id]
                      {
                        valid_fields: common_fields,
                  Severity: Minor
                  Found in app/models/region.rb - About 1 hr to fix

                    Method filter_settings has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.filter_settings
                        {
                          valid_fields: [
                            :id, :text, :is_taxonomic, :type_of_tag, :retired, :notes,
                            :creator_id, :created_at, :updater_id, :updated_at
                    Severity: Minor
                    Found in app/models/tag.rb - About 1 hr to fix

                      Method filter_settings has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.filter_settings
                          {
                            valid_fields: [:id, :name, :description, :stored_query, :created_at, :creator_id, :deleter_id, :deleted_at],
                            render_fields: [:id, :name, :description, :stored_query, :created_at, :creator_id, :deleter_id, :deleted_at],
                            text_fields: [:name, :description],
                      Severity: Minor
                      Found in app/models/saved_search.rb - About 1 hr to fix

                        Method poll_resque_and_media has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def poll_resque_and_media(expected_files, _media_type, _media_request_params, wait_max, job_id:, poll_delay: 0.4)
                              poll_locations = prepare_locations(expected_files)
                              existing_files = []
                              resque_status = nil
                        
                        
                        Severity: Minor
                        Found in app/modules/media_poll.rb - About 1 hr to fix

                          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/analysis_jobs_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 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

                          Severity
                          Category
                          Status
                          Source
                          Language