app/models/album_detector.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

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

  def self.detect_albums!(photo)
    photo_klass = photo.class
    photo_source = photo_klass.name.split(/(?=[A-Z])/).first
    album_detector_klass = "#{photo_source}AlbumDetector".constantize
    assign_default_album(photo)
Severity: Minor
Found in app/models/album_detector.rb by rubocop

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

You can set constructs you want to fold with CountAsOne. Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct will be counted as one line regardless of its actual size.

NOTE: The ExcludedMethods and IgnoredMethods configuration is deprecated and only kept for backwards compatibility. Please use AllowedMethods and AllowedPatterns instead. By default, there are no methods to allowed.

Example: CountAsOne: ['array', 'heredoc', 'method_call']

def m
  array = [       # +1
    1,
    2
  ]

  hash = {        # +3
    key: 'value'
  }

  <<~HEREDOC      # +1
    Heredoc
    content.
  HEREDOC

  foo(            # +1
    1,
    2
  )
end               # 6 points

Assignment Branch Condition size for detect_albums! is too high. [<6, 19, 1> 19.95/17]
Open

  def self.detect_albums!(photo)
    photo_klass = photo.class
    photo_source = photo_klass.name.split(/(?=[A-Z])/).first
    album_detector_klass = "#{photo_source}AlbumDetector".constantize
    assign_default_album(photo)
Severity: Minor
Found in app/models/album_detector.rb by rubocop

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 and https://en.wikipedia.org/wiki/ABC_Software_Metric.

Interpreting ABC size:

  • <= 17 satisfactory
  • 18..30 unsatisfactory
  • > 30 dangerous

You can have repeated "attributes" calls count as a single "branch". For this purpose, attributes are any method with no argument; no attempt is meant to distinguish actual attr_reader from other methods.

Example: CountRepeatedAttributes: false (default is true)

# `model` and `current_user`, referenced 3 times each,
 # are each counted as only 1 branch each if
 # `CountRepeatedAttributes` is set to 'false'

 def search
   @posts = model.active.visible_by(current_user)
             .search(params[:q])
   @posts = model.some_process(@posts, current_user)
   @posts = model.another_process(@posts, current_user)

   render 'pages/search/page'
 end

This cop also takes into account AllowedMethods (defaults to []) And AllowedPatterns (defaults to [])

Useless private_class_method access modifier.
Open

  private_class_method
Severity: Minor
Found in app/models/album_detector.rb by rubocop

Checks for redundant access modifiers, including those with no code, those which are repeated, and leading public modifiers in a class or module body. Conditionally-defined methods are considered as always being defined, and thus access modifiers guarding such methods are not redundant.

This cop has ContextCreatingMethods option. The default setting value is an empty array that means no method is specified. This setting is an array of methods which, when called, are known to create its own context in the module's current access context.

It also has MethodCreatingMethods option. The default setting value is an empty array that means no method is specified. This setting is an array of methods which, when called, are known to create other methods in the module's current access context.

Example:

# bad
class Foo
  public # this is redundant (default access is public)

  def method
  end
end

# bad
class Foo
  # The following is redundant (methods defined on the class'
  # singleton class are not affected by the private modifier)
  private

  def self.method3
  end
end

# bad
class Foo
  protected

  define_method(:method2) do
  end

  protected # this is redundant (repeated from previous modifier)

  [1,2,3].each do |i|
    define_method("foo#{i}") do
    end
  end
end

# bad
class Foo
  private # this is redundant (no following methods are defined)
end

# good
class Foo
  private # this is not redundant (a method is defined)

  def method2
  end
end

# good
class Foo
  # The following is not redundant (conditionally defined methods are
  # considered as always defining a method)
  private

  if condition?
    def method
    end
  end
end

# good
class Foo
  protected # this is not redundant (a method is defined)

  define_method(:method2) do
  end
end

Example: ContextCreatingMethods: concerning

# Lint/UselessAccessModifier:
#   ContextCreatingMethods:
#     - concerning

# good
require 'active_support/concern'
class Foo
  concerning :Bar do
    def some_public_method
    end

    private

    def some_private_method
    end
  end

  # this is not redundant because `concerning` created its own context
  private

  def some_other_private_method
  end
end

Example: MethodCreatingMethods: delegate

# Lint/UselessAccessModifier:
#   MethodCreatingMethods:
#     - delegate

# good
require 'active_support/core_ext/module/delegation'
class Foo
  # this is not redundant because `delegate` creates methods
  private

  delegate :method_a, to: :method_b
end

end at 19, 24 is not aligned with first_bucket_size = begin at 15, 4.
Open

                        end
Severity: Minor
Found in app/models/album_detector.rb by rubocop

Checks whether the end keyword of begin is aligned properly.

Two modes are supported through the EnforcedStyleAlignWith configuration parameter. If it's set to start_of_line (which is the default), the end shall be aligned with the start of the line where the begin keyword is. If it's set to begin, the end shall be aligned with the begin keyword.

Layout/EndAlignment cop aligns with keywords (e.g. if, while, case) by default. On the other hand, ||= begin that this cop targets tends to align with the start of the line, it defaults to EnforcedStyleAlignWith: start_of_line. These style can be configured by each cop.

Example: EnforcedStyleAlignWith: startofline (default)

# bad
foo ||= begin
          do_something
        end

# good
foo ||= begin
  do_something
end

Example: EnforcedStyleAlignWith: begin

# bad
foo ||= begin
  do_something
end

# good
foo ||= begin
          do_something
        end

rescue at 17, 24 is not aligned with first_bucket_size = begin at 15, 4.
Open

                        rescue StandardError
Severity: Minor
Found in app/models/album_detector.rb by rubocop

Checks whether the rescue and ensure keywords are aligned properly.

Example:

# bad
begin
  something
  rescue
  puts 'error'
end

# good
begin
  something
rescue
  puts 'error'
end

There are no issues that match your filters.

Category
Status