znamenica/dneslov

View on GitHub

Showing 2,171 of 2,171 total issues

Use the lambda method for multiline lambdas.
Open

   scope :with_calendary_title, -> context do
Severity: Minor
Found in app/models/memo.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

Avoid the use of Perl-style backrefs.
Open

         date = Time.parse("#{$2}.1970")
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Avoid the use of Perl-style backrefs.
Open

         date = Time.parse("#{$3}.1970") + ($2.to_i - 1) * 7
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Redundant self detected.
Open

      selector = self.select_values.dup | ["#{join_name}.*", "descriptions_#{scope_name}.text AS _title"]
Severity: Minor
Found in app/models/memo.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

Wrap stabby lambda arguments with parentheses.
Open

   scope :with_calendary_title, -> context do
Severity: Minor
Found in app/models/memo.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}

Space inside parentheses detected.
Open

      calendary_ids = Slug.where( text: calendaries, sluggable_type: 'Calendary' ).select( :sluggable_id )
Severity: Minor
Found in app/models/memo.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

      where( calendary_id: calendary_ids )
Severity: Minor
Found in app/models/memo.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected.
Open

         where( "unaccent(titles_memoes.text) ~* unaccent(?)", "\\m#{text}.*" ).or(
Severity: Minor
Found in app/models/memo.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Line is too long. [136/130]
Open

   validates :year_date, format: { with: /\A((0[1-9]|[1-2][0-9]|3[0-1])\.(0[1-9]|1[0-2])([%<>~][0-6])?|[+-]\d{1,3})\z/ }, if: :year_date
Severity: Minor
Found in app/models/memo.rb by rubocop

Use only ascii symbols in comments.
Open

# bond_to_id[int]             - ссылка на опорный помин, если nil, помин первичный
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).

Example:

# bad
# Translates from English to 日本語。

# good
# Translates from English to Japanese

Freeze mutable objects assigned to constants.
Open

   CONDITIONALS = {
      '<' => (1..7),
      '>' => (-7..-1),
      '%' => (0..6),
      '~' => (-3..3),
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Avoid the use of Perl-style backrefs.
Open

         days = ($2.to_i - 1) * 7 + daynum
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Avoid the use of Perl-style backrefs.
Open

         daynum = DAYS.index($1)
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Avoid the use of Perl-style backrefs.
Open

         date = Time.parse("#{$3}.1970") + ($2.to_i - 1) * 7
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Redundant self detected.
Open

      case self.year_date
Severity: Minor
Found in app/models/memo.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

Space inside parentheses detected.
Open

         where( "memoes.add_date ~* ?", "\\m#{text}.*" ).or(
Severity: Minor
Found in app/models/memo.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Use the lambda method for multiline lambdas.
Open

   scope :by_date, ->(dates_in, julian = false) do
Severity: Minor
Found in app/models/memo.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

Useless assignment to variable - as.
Open

      /`(?<as>[^']*)'/ =~ caller.grep(/delegation/)[1]
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Avoid the use of Perl-style backrefs.
Open

         days = ($2.to_i - 1) * 7 + daynum
Severity: Minor
Found in app/models/memo.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Line is too long. [200/130]
Open

      joins(joi).select(selector).group(:id, "#{as}_memories.short_name", "#{as}_events.happened_at", "#{as}_event_titles.text", "#{as}_titles.text", "#{as}_calendary_titles.text", "memoes.year_date")
Severity: Minor
Found in app/models/memo.rb by rubocop
Severity
Category
Status
Source
Language