QutBioacoustics/baw-server

View on GitHub

Showing 213 of 257 total issues

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

    def dir_list(path, bases, paging)
      items = paging[:items]
      page = paging[:page]
      offset = paging[:offset]
      raise 'Disabling paging is not supported for a directory listing' if paging[:disable_paging]
Severity: Minor
Found in app/modules/api/directory_renderer.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 csv_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.csv_query(user, project, site, audio_recording, start_offset, end_offset, timezone_name)
    # NOTE: if other modifications are made to the default_scope (like acts_as_paranoid does),
    # manually constructed queries like this need to be updated to match
    # (search for ':deleted_at' to find the relevant places)

Severity: Minor
Found in app/models/audio_event.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 validate_basic_class has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_basic_class(node, value)
      return if value.is_a?(NilClass) || value.is_a?(Integer) || value.is_a?(String) || value.is_a?(Float) ||
                value.is_a?(TrueClass) || value.is_a?(FalseClass)

      node_name = node.respond_to?(:name) ? node.name : '(custom item)'
Severity: Minor
Found in app/modules/filter/validate.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 error_notification has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def error_notification(to, from, job, error)
        raise ArgumentError, "Error is not a ruby error object #{error.inspect}." unless error.is_a?(StandardError)
        raise ArgumentError, "From is not a string #{from.inspect}." unless from.is_a?(String)
        raise ArgumentError, "To is not a string or Array #{to.inspect}." unless to.is_a?(String) || to.is_a?(Array)
        raise ArgumentError, "Job is not a hash #{job.inspect}." unless job.is_a?(Hash)
Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/mail/mailer.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 modify_command has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def modify_command(source, source_info, target, start_offset = nil, end_offset = nil, channel = nil, sample_rate = nil)
      raise Exceptions::FileNotFoundError, "Source does not exist: #{source}" unless File.exist? source
      raise Exceptions::FileAlreadyExistsError, "Target exists: #{target}" if File.exist? target
      raise ArgumentError, "Source and Target are the same file: #{target}" if source == target

Severity: Minor
Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.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::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 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 clipping_check has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def clipping_check(source, info_flattened)
      # check for clipping, zero signal
      # only if duration less than 4 minutes
      four_minutes_in_sec = 4.0 * 60.0
      if (info_flattened[:media_type] == 'audio/wav' ||
Severity: Minor
Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.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 set_view_model has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def set_view_model(job, error)
        job_class = job&.dig(:job_class)
        job_args = job&.dig(:job_args)
        job_queue = job&.dig(:job_queue)

Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/mail/mailer.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)
        raise ArgumentError, 'Hash must not be blank.' if hash.blank?

        check_hash(hash)
        raise ArgumentError, "Keys for #{hash} must not be empty." if expected_keys.blank?
Severity: Minor
Found in lib/gems/baw-workers/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 respond_with_fake_directory has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def respond_with_fake_directory(directory, children, base_directories, url_base_path, extra_payload = {}, is_head_request = false, api_opts = {})
Severity: Major
Found in app/modules/api/directory_renderer.rb - About 50 mins to fix

    Method csv_query has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def self.csv_query(user, project, site, audio_recording, start_offset, end_offset, timezone_name)
    Severity: Major
    Found in app/models/audio_event.rb - About 50 mins to fix

      Method modify_command has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def modify_command(source, source_info, target, start_offset = nil, end_offset = nil, channel = nil, sample_rate = nil)
      Severity: Major
      Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 50 mins to fix

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

            def respond_with_directory(directories, base_directories, url_base_path, extra_payload = {}, is_head_request = false, api_opts = {})
        Severity: Minor
        Found in app/modules/api/directory_renderer.rb - About 45 mins to fix

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

                def on_conflict(on_conflict, conflict_target, conflict_where)
                  @ast.on_conflict = Nodes::OnConflict.new.tap do |c|
                    c.action = make_conflict_action(on_conflict)
          
                    c.target = if conflict_target.is_a?(String)
          Severity: Minor
          Found in app/modules/baw/arel/upsert_manager.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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              statuses = start_checks
          
              timed_out = statuses.wait(10) == false
          
          
          Severity: Minor
          Found in app/controllers/status_controller.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 directory_list has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def directory_list(db, sqlite_path, path, items, offset, _max_items)
          Severity: Minor
          Found in app/modules/file_systems/sqlite.rb - About 45 mins to fix

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

                def validate_range(left, right)
                  return :other if OTHER == left && right.blank?
                  return :numbers if left == '0' && right == '9'
            
                  return :normal if /^[a-z]+$/ =~ left && /^[a-z]+$/ =~ right
            Severity: Minor
            Found in app/modules/alphabetical_paginator_query.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|
                          audio_info[audio_params[:uuid]] = audio_params
            Severity: Minor
            Found in lib/gems/baw-workers/lib/baw_workers/jobs/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 initialize has a Cognitive Complexity of 8 (exceeds 5 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 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 make_library_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def make_library_path(ar_value = nil, ae_value = nil)
                  return '/library' if ar_value.nil? && ae_value.nil?
            
                  ar_id, ae_id = nil
            
            
            Severity: Minor
            Found in app/modules/api/custom_url_helpers.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