znamenica/dneslov

View on GitHub
app/models/reading.rb

Summary

Maintainability
A
0 mins
Test Coverage

Block has too many lines. [35/25]
Open

   scope :with_markups, -> context do
      join_name = table.table_alias || table.name
      language_codes = [context[:locales]].flatten
      alphabeth_codes = Languageble.alphabeth_list_for(language_codes).flatten
      selector = self.select_values.dup
Severity: Minor
Found in app/models/reading.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Missing top-level class documentation comment.
Open

class Reading < ActiveRecord::Base
Severity: Minor
Found in app/models/reading.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Use the lambda method for multiline lambdas.
Open

   scope :with_markups, -> context do
Severity: Minor
Found in app/models/reading.rb by rubocop

This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.

Example: EnforcedStyle: linecountdependent (default)

# bad
f = lambda { |x| x }
f = ->(x) do
      x
    end

# good
f = ->(x) { x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: lambda

# bad
f = ->(x) { x }
f = ->(x) do
      x
    end

# good
f = lambda { |x| x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: literal

# bad
f = lambda { |x| x }
f = lambda do |x|
      x
    end

# good
f = ->(x) { x }
f = ->(x) do
      x
    end

Redundant self detected.
Open

      if self.select_values.dup.empty?
Severity: Minor
Found in app/models/reading.rb by rubocop

This cop checks for redundant uses of self.

The usage of self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

  • Calling an attribute writer to prevent an local variable assignment.

Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

Note we allow uses of self with operators because it would be awkward otherwise.

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

Do not use spaces between -> and opening brace in lambda literals
Open

   scope :with_markups, -> context do
      join_name = table.table_alias || table.name
      language_codes = [context[:locales]].flatten
      alphabeth_codes = Languageble.alphabeth_list_for(language_codes).flatten
      selector = self.select_values.dup
Severity: Minor
Found in app/models/reading.rb by rubocop

This cop checks for spaces between -> and opening parameter brace in lambda literals.

Example: EnforcedStyle: requirenospace (default)

# bad
  a = -> (x, y) { x + y }

  # good
  a = ->(x, y) { x + y }

Example: EnforcedStyle: require_space

# bad
  a = ->(x, y) { x + y }

  # good
  a = -> (x, y) { x + y }

Wrap stabby lambda arguments with parentheses.
Open

   scope :with_markups, -> context do
Severity: Minor
Found in app/models/reading.rb by rubocop

Check for parentheses around stabby lambda arguments. There are two different styles. Defaults to require_parentheses.

Example: EnforcedStyle: require_parentheses (default)

# bad
->a,b,c { a + b + c }

# good
->(a,b,c) { a + b + c}

Example: EnforcedStyle: requirenoparentheses

# bad
->(a,b,c) { a + b + c }

# good
->a,b,c { a + b + c}

Use 3 (not 2) spaces for indentation.
Open

        selector.unshift("#{join_name}.*")
Severity: Minor
Found in app/models/reading.rb by rubocop

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Trailing whitespace detected.
Open

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

%i-literals should be delimited by [ and ].
Open

   enum kind: %i(custom vespers matins lithurgy dinning hours)
Severity: Minor
Found in app/models/reading.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Redundant self detected.
Open

      selector = self.select_values.dup
Severity: Minor
Found in app/models/reading.rb by rubocop

This cop checks for redundant uses of self.

The usage of self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

  • Calling an attribute writer to prevent an local variable assignment.

Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

Note we allow uses of self with operators because it would be awkward otherwise.

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

      if self.select_values.dup.empty?
Severity: Minor
Found in app/models/reading.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

There are no issues that match your filters.

Category
Status