QutBioacoustics/baw-server

View on GitHub

Showing 257 of 257 total issues

Function createMarker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function createMarker(map, latLng, text, isInfoWindowOpen, draggable) {
    var instructions = 'Drag marker to site location. Delete Latitude and Longitude to specify no location.';

    // calculate defaults
    var draggableValue = (typeof draggable !== 'undefined' || !draggable) ? draggable : false;
Severity: Minor
Found in app/assets/javascripts/shared.js - 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 get_existing_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_existing_files(poll_locations)
      existing_files = []

      poll_locations.each do |location|
        #dir = location[:dir]
Severity: Minor
Found in app/modules/media_poll.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 get_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def get_config(raw_opts)
          if raw_opts[:config_file] && raw_opts[:config_string]
            raise ArgumentError, 'Must provide only one of config_file or config_string.'
          end
          if !raw_opts[:config_file] && !raw_opts[:config_string]
Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/jobs/analysis/payload.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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    return system_mutate if system_job?

    do_load_resource
    do_authorize_instance
Severity: Minor
Found in app/controllers/analysis_jobs_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 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def analysis_jobs
    do_load_resource
    do_authorize_instance

    @user_analysis_jobs = Access::ByUserModified.analysis_jobs(@user)
Severity: Minor
Found in app/controllers/user_accounts_controller.rb and 1 other location - About 25 mins to fix
app/controllers/user_accounts_controller.rb on lines 171..182

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def saved_searches
    do_load_resource
    do_authorize_instance

    @user_saved_searches = Access::ByUserModified.saved_searches(@user)
Severity: Minor
Found in app/controllers/user_accounts_controller.rb and 1 other location - About 25 mins to fix
app/controllers/user_accounts_controller.rb on lines 187..198

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def update
      @tag_group = TagGroup.find(params[:id])

      respond_to do |format|
        if @tag_group.update(tag_group_params)
Severity: Minor
Found in app/controllers/admin/tag_groups_controller.rb and 1 other location - About 25 mins to fix
app/controllers/admin/tags_controller.rb on lines 76..83

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 29.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language