app/models/audio_recording.rb

Summary

Maintainability
A
35 mins
Test Coverage

Mass assignment is not restricted using attr_accessible
Open

class AudioRecording < ActiveRecord::Base
Severity: Critical
Found in app/models/audio_recording.rb by brakeman

This warning comes up if a model does not limit what attributes can be set through mass assignment.

In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

Note that disabling mass assignment globally will suppress these warnings.

Assignment Branch Condition size for updated_since is too high. [25.96/15]
Open

  def self.updated_since(date)
    # AudioRecording.where( <AudioRecording or its join tables is newer than date>  )

    audio_recordings =                AudioRecording.arel_table
    taggings =                        Tagging.arel_table
Severity: Minor
Found in app/models/audio_recording.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [19/10]
Open

  def self.updated_since(date)
    # AudioRecording.where( <AudioRecording or its join tables is newer than date>  )

    audio_recordings =                AudioRecording.arel_table
    taggings =                        Tagging.arel_table
Severity: Minor
Found in app/models/audio_recording.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

TODO found
Open

  # TODO: add more content_types
Severity: Minor
Found in app/models/audio_recording.rb by fixme

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

  def attachment_attributes_valid?
    %i[size content_type].each do |attr_name|
      enum = attachment_options[attr_name]
      unless enum.nil? || enum.include?(send(attr_name))
        errors.add attr_name, I18n.t(
Severity: Minor
Found in app/models/audio_recording.rb and 2 other locations - About 35 mins to fix
app/models/image_file.rb on lines 75..83
app/models/video.rb on lines 85..93

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 36.

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

Use next to skip iteration.
Open

      unless enum.nil? || enum.include?(send(attr_name))
Severity: Minor
Found in app/models/audio_recording.rb by rubocop

Use next to skip iteration instead of a condition at the end.

Example: EnforcedStyle: skipmodifierifs (default)

# bad
[1, 2].each do |a|
  if a == 1
    puts a
  end
end

# good
[1, 2].each do |a|
  next unless a == 1
  puts a
end

# good
[1, 2].each do |o|
  puts o unless o == 1
end

Example: EnforcedStyle: always

# With `always` all conditions at the end of an iteration needs to be
# replaced by next - with `skip_modifier_ifs` the modifier if like
# this one are ignored: `[1, 2].each { |a| return 'yes' if a == 1 }`

# bad
[1, 2].each do |o|
  puts o unless o == 1
end

# bad
[1, 2].each do |a|
  if a == 1
    puts a
  end
end

# good
[1, 2].each do |a|
  next unless a == 1
  puts a
end

There are no issues that match your filters.

Category
Status