QutBioacoustics/baw-workers

View on GitHub

Showing 75 of 86 total issues

Method action_summary has a Cognitive Complexity of 43 (exceeds 5 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 6 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 run_single has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

      def run_single(existing_file, audio_params, is_real_run)
        # get existing file info and comparisons between expected and actual
        existing_file_info = @file_info.audio_info(existing_file)

        @logger.debug(@class_name) {
Severity: Minor
Found in lib/baw-workers/audio_check/work_helper.rb - About 5 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 run has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

      def run(opts)
        if !opts.include?(:settings_file) || opts[:settings_file].blank?
          opts[:settings_file] = File.join(File.dirname(__FILE__), '..', 'settings', 'settings.default.yml')
        end

Severity: Minor
Found in lib/baw-workers/config.rb - About 5 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 run has 130 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def run(opts)
        if !opts.include?(:settings_file) || opts[:settings_file].blank?
          opts[:settings_file] = File.join(File.dirname(__FILE__), '..', 'settings', 'settings.default.yml')
        end

Severity: Major
Found in lib/baw-workers/config.rb - About 5 hrs to fix

    Method run_single has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def run_single(existing_file, audio_params, is_real_run)
            # get existing file info and comparisons between expected and actual
            existing_file_info = @file_info.audio_info(existing_file)
    
            @logger.debug(@class_name) {
    Severity: Major
    Found in lib/baw-workers/audio_check/work_helper.rb - About 4 hrs to fix

      Method logged_csv_line has a Cognitive Complexity of 27 (exceeds 5 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)
                csv_headers = [
      Severity: Minor
      Found in lib/baw-workers/audio_check/csv_helper.rb - About 3 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

      File work_helper.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module BawWorkers
        module AudioCheck
          class WorkHelper
      
            def initialize(logger, file_info, api_comm)
      Severity: Minor
      Found in lib/baw-workers/audio_check/work_helper.rb - About 3 hrs to fix

        Class MultiLogger has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class MultiLogger < Logger
        
            # Array of Loggers to be logged to. These can be anything that acts reasonably like a Logger.
            attr_accessor :loggers
        
        
        Severity: Minor
        Found in lib/baw-workers/multi_logger.rb - About 3 hrs to fix

          Method run has 75 lines of code (exceeds 25 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: Major
          Found in lib/baw-workers/harvest/single_file.rb - About 3 hrs to fix

            Method logged_csv_line has 70 lines of code (exceeds 25 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)
                      csv_headers = [
            Severity: Major
            Found in lib/baw-workers/audio_check/csv_helper.rb - About 2 hrs to fix

              Method compare_info has a Cognitive Complexity of 20 (exceeds 5 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 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 error_notification has a Cognitive Complexity of 20 (exceeds 5 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 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

              File api_communicator.rb has 275 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module BawWorkers
                class ApiCommunicator
              
                  attr_accessor :logger
              
              
              Severity: Minor
              Found in lib/baw-workers/api_communicator.rb - About 2 hrs to fix

                Method run_web has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def run_web(core_logger, mailer_logger, resque_logger, audio_tools_logger, settings, is_test)
                        
                        # configure basic attributes first
                        BawWorkers::Config.temp_dir = File.expand_path(settings.paths.temp_dir)
                
                
                Severity: Major
                Found in lib/baw-workers/config.rb - About 2 hrs to fix

                  Class ResqueApi has 23 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class ResqueApi
                      class << self
                  
                        # Is this type of job with these args currently queued?
                        # @param [Class] klass
                  Severity: Minor
                  Found in lib/baw-workers/resque_api.rb - About 2 hrs to fix

                    Method file_name_datetime has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def file_name_datetime(file_name, utc_offset = nil)
                          result = {}
                          regex = /^(.*)(\d{4})(\d{2})(\d{2})(-|_|T)?(\d{2})(\d{2})(\d{2})([+\-]\d{4}|[+\-]\d{1,2}:\d{2}|[+\-]\d{1,2}|Z)?(.*)\.([a-zA-Z0-9]+)$/
                          file_name.scan(regex) do |prefix, year, month, day, separator, hour, minute, second, offset, suffix, extension|
                            result[:raw] = {
                    Severity: Minor
                    Found in lib/baw-workers/file_info.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 send_request has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def send_request(description, method, host, port, endpoint, security_info = {auth_token: nil, cookies: nil}, body = nil)
                    
                          case method
                            when :get
                              request = Net::HTTP::Get.new(endpoint)
                    Severity: Major
                    Found in lib/baw-workers/api_communicator.rb - About 2 hrs to fix

                      Method send_request has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def send_request(description, method, host, port, endpoint, security_info = {auth_token: nil, cookies: nil}, body = nil)
                      
                            case method
                              when :get
                                request = Net::HTTP::Get.new(endpoint)
                      Severity: Minor
                      Found in lib/baw-workers/api_communicator.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 run has 55 lines of code (exceeds 25 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: Major
                      Found in lib/baw-workers/audio_check/work_helper.rb - About 2 hrs to fix

                        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|
                        Severity: Major
                        Found in lib/baw-workers/audio_check/csv_helper.rb - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language