QutBioacoustics/baw-server

View on GitHub

Showing 213 of 257 total issues

Method convert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def convert(value, inline, words)
      return nil if value.blank?

      html = Kramdown::Document.new(value, KRAMDOWN_OPTIONS).to_html

Severity: Minor
Found in app/modules/custom_render.rb - About 25 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_integer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_integer(value, min = nil, max = nil)
      raise CustomErrors::FilterArgumentError, 'Value must not be blank' if value.blank?
      if value.blank? || value != value.to_i
        raise CustomErrors::FilterArgumentError, "Value must be an integer, got #{value}"
      end
Severity: Minor
Found in app/modules/filter/validate.rb - About 25 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_visualise_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def make_visualise_path(value)
      raise ArgumentError, 'Must provide project or site' if value.blank?

      link = '/visualize?'

Severity: Minor
Found in app/modules/api/custom_url_helpers.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def update
      @script = Script.find(params[:id])

      unless @script.is_last_version?
        respond_to do |format|
Severity: Minor
Found in app/controllers/admin/scripts_controller.rb - About 25 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 safe_result has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def safe_result(promise, index:)
    return 'unknown' if promise.pending?

    # result returns a tuple (an array) of
    # [fulfilled?, value, reason]
Severity: Minor
Found in app/controllers/status_controller.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    do_load_resource
    do_authorize_instance

    relevant_params = audio_recording_params
Severity: Minor
Found in app/controllers/audio_recordings_controller.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    do_load_resource
    get_audio_event
    do_authorize_instance

Severity: Minor
Found in app/controllers/audio_event_comments_controller.rb - About 25 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 generate_yaml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def self.generate_yaml(project_id, site_id, uploaders, recursive:, utc_offset: nil)
          raise ArgumentError, 'recursive must be `true` or `false`' unless [true, false].include?(recursive)

          uploader_section =
            if uploaders.blank?
Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/jobs/harvest/metadata.rb - About 25 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_source has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def check_source(path)
      raise Exceptions::FileNotFoundError, 'Source path was empty or nil' if path.nil? || (path.is_a?(String) && path.empty?)
      path = Pathname(path)

      # Maybe worth resolving symlinks to a realpath, but currently does not cause any failures without
Severity: Minor
Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_base.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def modify_command(source, target)
      source = Pathname(source)
      target = Pathname(target)
      raise ArgumentError, "Source is not a png file: #{source}" unless source.extname == '.png'
      raise ArgumentError, "Target is not a png file: : #{target}" unless target.extname == '.png'
Severity: Minor
Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/image_image_magick.rb - About 25 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 hash_sha256_io has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def hash_sha256_io(io)
      unless io_ish?(io)
        raise ArgumentError,
              "io not an IO, it is an #{io.class}"
      end
Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/io.rb - About 25 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 format_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def self.format_command(opts, command_opts)
          command_format = opts[:command_format].dup

          command_placeholders = BawWorkers::Jobs::Analysis::Runner.extract_command_placeholders(opts)
          allowed_placeholders = BawWorkers::Jobs::Analysis::Payload::COMMAND_PLACEHOLDERS
Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/jobs/analysis/runner.rb - About 25 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 normalise_datetime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def normalise_datetime(value)
        raise ArgumentError, 'Expected value to be a ActiveSupport::TimeWithZone, got blank.' if value.blank?

        return value if value.is_a?(ActiveSupport::TimeWithZone)

Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/validation.rb - About 25 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