QutBioacoustics/baw-workers

View on GitHub

Showing 75 of 86 total issues

Method execute has 49 lines of code (exceeds 25 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 1 hr to fix

    Method action_perform has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def action_perform(analysis_params)
              analysis_params_sym = BawWorkers::Analysis::Payload.normalise_opts(analysis_params)
    
              BawWorkers::Config.logger_worker.info(logger_name) {
                "Started analysis using '#{format_params_for_log(analysis_params_sym)}'."
    Severity: Minor
    Found in lib/baw-workers/analysis/action.rb - About 1 hr to fix

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

              def action_perform(analysis_params)
                analysis_params_sym = BawWorkers::Analysis::Payload.normalise_opts(analysis_params)
      
                BawWorkers::Config.logger_worker.info(logger_name) {
                  "Started analysis using '#{format_params_for_log(analysis_params_sym)}'."
      Severity: Minor
      Found in lib/baw-workers/analysis/action.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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def run(audio_params, is_real_run)
              # validate params
              audio_params_sym = BawWorkers::AudioCheck::WorkHelper.validate(audio_params)
      
              if is_real_run
      Severity: Minor
      Found in lib/baw-workers/audio_check/work_helper.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 error_notification has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def error_notification(to, from, job, error)
              fail ArgumentError, "Error is not a ruby error object #{error.inspect}." unless error.is_a?(StandardError)
              fail ArgumentError, "From is not a string #{from.inspect}." unless from.is_a?(String)
              fail ArgumentError, "To is not a string or Array #{to.inspect}." unless (to.is_a?(String) || to.is_a?(Array))
              fail ArgumentError, "Job is not a hash #{job.inspect}." unless job.is_a?(Hash)
      Severity: Minor
      Found in lib/baw-workers/mail/mailer.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/baw-workers/audio_check/csv_helper.rb - About 1 hr to fix

          Method process has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def process(path, top_dir, recurse = true)
                  dirs = []
                  results = []
          
                  path = File.expand_path(path)
          Severity: Minor
          Found in lib/baw-workers/harvest/gather_files.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 normalise_path has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def normalise_path(path, top_level_dir = nil)
                  path = '' if path.nil?
          
                  # first replace '..', '~', '//', '\\', '/./', '\.\'
                  # ensure no double or more slashes
          Severity: Minor
          Found in lib/baw-workers/validation.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 update_analysis_jobs_item_status has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def update_analysis_jobs_item_status(analysis_job_id, audio_recording_id, status, security_info)
                approved_statuses = [:working, :successful, :failed, :timed_out, :cancelled]
          
                raise "Cannot set status to `#{status}`" unless approved_statuses.include?(status)
          
          
          Severity: Minor
          Found in lib/baw-workers/api_communicator.rb - About 1 hr to fix

            Method parse_file_path has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def parse_file_path(file_path)
            
                    file_name = File.basename(file_path)
                    file_name_split = file_name.split('_')
            
            
            Severity: Minor
            Found in lib/baw-workers/storage/audio_original.rb - About 1 hr to fix

              Method compare_info has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def compare_info(existing_file, existing_file_info, audio_params)
                      correct = :pass
                      wrong = :fail
              
                      bit_rate_bps_delta = 10000 # due to difference for asf files of 1300-2000 bps (set large to catch only very different bit rates)
              Severity: Minor
              Found in lib/baw-workers/audio_check/work_helper.rb - About 1 hr to fix

                Method rename_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                      def rename_file(existing_file, file_name_utc, is_real_run)
                
                        # create all needed information
                        existing_path = existing_file
                        existing_name = File.basename(existing_path)
                Severity: Minor
                Found in lib/baw-workers/audio_check/work_helper.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 update_analysis_jobs_item_status has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update_analysis_jobs_item_status(analysis_job_id, audio_recording_id, status, security_info)
                      approved_statuses = [:working, :successful, :failed, :timed_out, :cancelled]
                
                      raise "Cannot set status to `#{status}`" unless approved_statuses.include?(status)
                
                
                Severity: Minor
                Found in lib/baw-workers/api_communicator.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 get_folder_settings has 31 lines of code (exceeds 25 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 1 hr to fix

                  Method rename_file has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def rename_file(existing_file, file_name_utc, is_real_run)
                  
                          # create all needed information
                          existing_path = existing_file
                          existing_name = File.basename(existing_path)
                  Severity: Minor
                  Found in lib/baw-workers/audio_check/work_helper.rb - About 1 hr to fix

                    Method action_summary has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def action_summary(results)
                              base_path = Pathname.new(results[:path])
                              files = results[:results]
                    
                              BawWorkers::Config.logger_worker.debug(self.name) {
                    Severity: Minor
                    Found in lib/baw-workers/harvest/action.rb - About 1 hr to fix

                      Method process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def process(path, top_dir, recurse = true)
                              dirs = []
                              results = []
                      
                              path = File.expand_path(path)
                      Severity: Minor
                      Found in lib/baw-workers/harvest/gather_files.rb - About 1 hr to fix

                        Method request_login has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def request_login
                              login_response = send_request('Login request', :post, host, port, endpoint_login, nil, {email: user, password: password})
                        
                              # get cookies
                              # from http://stackoverflow.com/a/9320190/31567
                        Severity: Minor
                        Found in lib/baw-workers/api_communicator.rb - About 1 hr to fix

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

                                def validate_job_id(opts)
                                  provided = validate_msg_provided(opts)
                                  fail ArgumentError, "#{validate_msg_base} job_id. #{provided}" unless opts.include? :job_id
                                  fail ArgumentError, "job_id must not be blank. #{provided}" if opts[:job_id].blank?
                          
                          
                          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 resolve has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def resolve(payload)
                                  return payload unless payload.is_a?(Hash)
                          
                                  has_string = payload.has_key?(PARTIAL_PAYLOAD_KEY)
                                  has_symbol = payload.has_key?(PARTIAL_PAYLOAD_KEY.to_sym)
                          Severity: Minor
                          Found in lib/baw-workers/partial_payload.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