QutBioacoustics/baw-server

View on GitHub

Showing 213 of 257 total issues

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

    def prepare_locations(files)
      poll_locations = []
      regex_check = %r{\A(?:/?[0-9a-zA-Z_\-.]+)+\z}
      files.each do |raw_file|
        next if raw_file.nil?
Severity: Minor
Found in app/modules/media_poll.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 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)
        raise ArgumentError, "#{validate_msg_base} job_id. #{provided}" unless opts.include? :job_id
        raise ArgumentError, "job_id must not be blank. #{provided}" if opts[:job_id].blank?

Severity: Minor
Found in lib/gems/baw-workers/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 send_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def send_message(logged_in_user, model, rails_request, subject_prefix, template_name)
    @info = {
      logged_in_user_name: logged_in_user.blank? ? nil : logged_in_user.user_name,
      model: model,
      sender_email: model.email.blank? ? nil : model.email,
Severity: Minor
Found in app/mailers/public_mailer.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/gems/baw-workers/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 safe_perform! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def safe_perform!(&block)
        update_status(status: STATUS_WORKING)

        kill! if should_kill?

Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/active_job/status.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 parse_ffprobe_output has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_ffprobe_output(source, execute_msg)
      # ffprobe std err contains info (separate on first equals(=))

      result = {}
      ffprobe_current_block_name = ''
Severity: Minor
Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.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 check_sample_rate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def check_sample_rate(target, modify_parameters = {}, source_info = {})
      if modify_parameters.include?(:sample_rate)
        sample_rate = modify_parameters[:sample_rate].to_i

        # source_info sample_rate_hertz should match modify_parameters original_sample_rate if both are supplied
Severity: Minor
Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.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_sign_in_params has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_sign_in_params
      # available parameters
      email = params[:email].presence
      login = params[:login].presence
      password = params[:password].presence
Severity: Minor
Found in app/modules/api/api_auth.rb - About 1 hr to fix

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

      def self.fetch_stats(current_user)
        online_window = 2.hours.ago
        recent_window = 1.month.ago
        recent_limit = 10
        {
    Severity: Minor
    Found in app/controllers/stats_controller.rb - About 1 hr to fix

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

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

        Method index has 27 lines of code (exceeds 25 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

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

            def index
              base_path = "#{Rails.root}/public"
              image_base = '/system/home/'
              json_data_file = "#{base_path}#{image_base}animals.json"
              sensor_tree = "#{base_path}#{image_base}sensor_tree.jpg"
          Severity: Minor
          Found in app/controllers/public_controller.rb - About 1 hr to fix

            Method generate_spectrogram has 26 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]
            
                      return target_existing if target_existing.any?
            Severity: Minor
            Found in lib/gems/baw-workers/lib/baw_workers/jobs/media/work_helper.rb - About 1 hr to fix

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

                      def begin(params)
                        # 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/gems/baw-workers/lib/baw_workers/jobs/analysis/status.rb - About 1 hr to fix

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

                      def update_status(*messages, status: nil, progress: nil, total: nil)
                        ensure_status
                
                        status ||= @status.status
                        unless TERMINAL_STATUSES.include?(status) || status == STATUS_WORKING
                Severity: Minor
                Found in lib/gems/baw-workers/lib/baw_workers/active_job/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/gems/baw-workers/lib/baw_workers/jobs/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/gems/baw-workers/lib/baw_workers/jobs/media/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/gems/baw-workers/lib/baw_workers/jobs/audio_check/csv_helper.rb - About 1 hr to fix

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

                          def consistent_associations
                            if !study.nil? && !question.nil?
                              unless study.question_ids.include?(question.id)
                                errors.add(:question_id, 'parent question is not associated with parent study')
                              end
                        Severity: Minor
                        Found in app/models/response.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 update has a Cognitive Complexity of 9 (exceeds 5 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 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

                        Severity
                        Category
                        Status
                        Source
                        Language