QutBioacoustics/baw-workers

View on GitHub

Showing 75 of 86 total issues

Method existing_files has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def existing_files
        existing_dirs.each do |dir|
          Find.find(dir) do |path|
            if FileTest.directory?(path)
              if File.basename(path)[0] == ?.
Severity: Minor
Found in lib/baw-workers/storage/common.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 read_audio_recording_csv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def read_audio_recording_csv(csv_file)
        index_to_key_map = {
            id: 0,
            uuid: 1,
            recorded_date: 2,
Severity: Minor
Found in lib/baw-workers/read_csv.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 generate_spectrogram has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def generate_spectrogram(modify_parameters = {})
        cache_spectrogram_info = @spectrogram_cache.path_info(modify_parameters)
        target_existing = cache_spectrogram_info[:existing]

        if target_existing.blank?
Severity: Minor
Found in lib/baw-workers/media/work_helper.rb - About 1 hr to fix

    Method read_audio_recording_csv has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def read_audio_recording_csv(csv_file)
            index_to_key_map = {
                id: 0,
                uuid: 1,
                recorded_date: 2,
    Severity: Minor
    Found in lib/baw-workers/read_csv.rb - About 1 hr to fix

      Method end has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def end(params, status)
              # is system job? then ignore - we have no status tracking
              return if should_not_process?(params)
      
              analysis_job_id = params[:job_id]
      Severity: Minor
      Found in lib/baw-workers/analysis/status.rb - About 1 hr to fix

        Method from_csv has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def from_csv(csv_file, config_file, command_file)
                csv_path = BawWorkers::Validation.normalise_file(csv_file)
                config_path = BawWorkers::Validation.normalise_file(config_file)
                command_path = BawWorkers::Validation.normalise_file(command_file)
        
        
        Severity: Minor
        Found in lib/baw-workers/analysis/payload.rb - About 1 hr to fix

          Method initialize has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                    audio_base, spectrogram,
                    audio_original, audio_cache, spectrogram_cache,
                    file_info, logger, temp_dir)
          Severity: Major
          Found in lib/baw-workers/media/work_helper.rb - About 1 hr to fix

            Method log_csv_line has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def log_csv_line(file_path, exists, moved_path = nil,
                                   compare_hash = nil, api_result_hash = nil,
                                   api_response = nil, review_level = :none_all_good,
                                   audio_recording_id)
            Severity: Major
            Found in lib/baw-workers/audio_check/work_helper.rb - About 1 hr to fix

              Method logged_csv_line has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def logged_csv_line(file_path, exists, moved_path = nil,
                                          compare_hash = nil, api_result_hash = nil,
                                          api_response = nil, review_level = :none_all_good,
                                          audio_recording_id)
              Severity: Major
              Found in lib/baw-workers/audio_check/csv_helper.rb - About 1 hr to fix

                Method run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def run(input, recurse = true)
                        results = []
                
                        @logger.info(@class_name) { 'Gathering files.' }
                
                
                Severity: Minor
                Found in lib/baw-workers/harvest/gather_files.rb - About 55 mins 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 end has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def end(params, status)
                        # is system job? then ignore - we have no status tracking
                        return if should_not_process?(params)
                
                        analysis_job_id = params[:job_id]
                Severity: Minor
                Found in lib/baw-workers/analysis/status.rb - About 55 mins 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 check_custom_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def check_custom_hash(hash, expected_keys)
                        fail ArgumentError, 'Hash must not be blank.' if hash.blank?
                        check_hash(hash)
                        fail ArgumentError, "Keys for #{hash} must not be empty." if expected_keys.blank?
                        fail ArgumentError, "Keys for #{hash} must be an array." unless expected_keys.is_a?(Array)
                Severity: Minor
                Found in lib/baw-workers/validation.rb - About 55 mins 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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def execute(prepared_opts, opts)
                        BawWorkers::Validation.check_custom_hash(prepared_opts, BawWorkers::Analysis::Payload::COMMAND_PLACEHOLDERS)
                        BawWorkers::Validation.check_custom_hash(opts, BawWorkers::Analysis::Payload::OPTS_FIELDS)
                        BawWorkers::Analysis::Runner.check_command_format(opts)
                
                
                Severity: Minor
                Found in lib/baw-workers/analysis/runner.rb - About 55 mins 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 send_request has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def send_request(description, method, host, port, endpoint, security_info = {auth_token: nil, cookies: nil}, body = nil)
                Severity: Major
                Found in lib/baw-workers/api_communicator.rb - About 50 mins to fix

                  Method run_web has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def run_web(core_logger, mailer_logger, resque_logger, audio_tools_logger, settings, is_test)
                  Severity: Minor
                  Found in lib/baw-workers/config.rb - About 45 mins to fix

                    Method get_folder_settings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def get_folder_settings(file)
                            unless File.file?(file)
                              @logger.debug(@class_name) { "Harvest directory config file was not found '#{file}'." }
                              return {}
                            end
                    Severity: Minor
                    Found in lib/baw-workers/harvest/gather_files.rb - About 45 mins 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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def run(file_info_hash, is_real_run, copy_on_success = false)
                    
                            file_info_hash.deep_symbolize_keys!
                    
                            project_id = file_info_hash[:project_id]
                    Severity: Minor
                    Found in lib/baw-workers/harvest/single_file.rb - About 45 mins 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 file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def file(path, top_dir, dir_settings = {})
                            unless File.file?(path)
                              msg = "'#{path}' is not a file."
                              @logger.error(@class_name) { msg }
                              fail ArgumentError, msg
                    Severity: Minor
                    Found in lib/baw-workers/harvest/gather_files.rb - About 45 mins 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 a Cognitive Complexity of 8 (exceeds 5 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|
                    Severity: Minor
                    Found in lib/baw-workers/audio_check/csv_helper.rb - About 45 mins 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 get_analysis_jobs_item_status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_analysis_jobs_item_status(analysis_job_id, audio_recording_id, security_info)
                          endpoint = endpoint_analysis_jobs_item_update_status
                                         .gsub(':audio_recording_id', audio_recording_id.to_s)
                                         .gsub(':analysis_job_id', analysis_job_id.to_s)
                    
                    
                    Severity: Minor
                    Found in lib/baw-workers/api_communicator.rb - About 45 mins 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