znamenica/dneslov

View on GitHub

Showing 2,171 of 2,171 total issues

Use def without parentheses.
Open

   def validate_each(record, attribute, value)

This cops checks for parentheses around the arguments in method definitions. Both instance and class/singleton methods are checked.

Example: EnforcedStyle: require_parentheses (default)

# The `require_parentheses` style requires method definitions
# to always use parentheses

# bad
def bar num1, num2
  num1 + num2
end

def foo descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name
  do_something
end

# good
def bar(num1, num2)
  num1 + num2
end

def foo(descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name)
  do_something
end

Example: EnforcedStyle: requirenoparentheses

# The `require_no_parentheses` style requires method definitions
# to never use parentheses

# bad
def bar(num1, num2)
  num1 + num2
end

def foo(descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name)
  do_something
end

# good
def bar num1, num2
  num1 + num2
end

def foo descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name
  do_something
end

Example: EnforcedStyle: requirenoparenthesesexceptmultiline

# The `require_no_parentheses_except_multiline` style prefers no
# parantheses when method definition arguments fit on single line,
# but prefers parantheses when arguments span multiple lines.

# bad
def bar(num1, num2)
  num1 + num2
end

def foo descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name
  do_something
end

# good
def bar num1, num2
  num1 + num2
end

def foo(descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name)
  do_something
end

Interpolation in single quoted string detected. Use double quoted strings if you need interpolation.
Open

               ру_РУ: "Пятница \#{week}-я по Пасхе"
Severity: Minor
Found in app/services/memo_service.rb by rubocop

This cop checks for interpolation in a single quoted string.

Example:

# bad

foo = 'something with #{interpolation} inside'

Example:

# good

foo = "something with #{interpolation} inside"

Avoid multi-line chains of blocks.
Open

      end.flatten.map { |x| [ x.keys.first, x.values.first ] }.to_h

This cop checks for chaining of a block after another block that spans multiple lines.

Example:

Thread.list.find_all do |t|
  t.alive?
end.map do |t|
  t.object_id
end

Use 3 (not 2) spaces for indentation.
Open

  require "rubygems"
Severity: Minor
Found in bin/spring 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

unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

      time = Resource.order(updated_at: :desc).first&.updated_at || Time.at(0) # last for updated_at or settingize
Severity: Minor
Found in app/services/image_sync_service.rb by rubocop

Use alias instead of alias_method in a module body.
Open

   alias_method :orig_structurally_incompatible_values_for, :structurally_incompatible_values_for
Severity: Minor
Found in lib/extensions.rb by rubocop

This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

Example: EnforcedStyle: prefer_alias (default)

# bad
alias_method :bar, :foo
alias :bar :foo

# good
alias bar foo

Example: EnforcedStyle: preferaliasmethod

# bad
alias :bar :foo
alias bar foo

# good
alias_method :bar, :foo

unexpected token kEND (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

end
Severity: Minor
Found in app/services/image_sync_service.rb by rubocop

Use && instead of and.
Open

      scope.where(:id => record.id).exists? and !@user.nil?
Severity: Minor
Found in app/policies/scriptum_policy.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Align the operands of an expression in an assignment spanning multiple lines.
Open

         "(KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
Severity: Minor
Found in lib/concerns/auth/github.rb by rubocop

This cop checks the indentation of the right hand side operand in binary operations that span more than one line.

Example:

# bad
if a +
b
  something
end

# good
if a +
   b
  something
end

Align the parameters of a method call if they span more than one line.
Open

               message: I18n.t('activerecord.errors.invalid_language_char', alphabeth: record.alphabeth_code, chars: chars))

Here we check if the parameters on a multi-line method call or definition are aligned.

Example: EnforcedStyle: withfirstparameter (default)

# good

foo :bar,
    :baz

# bad

foo :bar,
  :baz

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz

unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

         t = (Resource.last&.created_at || Time.at(10**10)) - 5.minutes
Severity: Minor
Found in lib/tasks/dneslov.rake by rubocop

Use the new Ruby 1.9 hash syntax.
Open

      scope.where(:id => record.id).exists? and !@user.nil?
Severity: Minor
Found in app/policies/item_policy.rb by rubocop

This cop checks hash literal syntax.

It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

A separate offense is registered for each problematic pair.

The supported styles are:

  • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
  • hash_rockets - forces use of hash rockets for all hashes
  • nomixedkeys - simply checks for hashes with mixed syntaxes
  • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

Example: EnforcedStyle: ruby19 (default)

# bad
{:a => 2}
{b: 1, :c => 2}

# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden

Example: EnforcedStyle: hash_rockets

# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}

# good
{:a => 1, :b => 2}

Example: EnforcedStyle: nomixedkeys

# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}

# good
{:a => 1, :b => 2}
{c: 1, d: 2}

Example: EnforcedStyle: ruby19nomixed_keys

# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets

# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}

Align the parameters of a method call if they span more than one line.
Open

               message: I18n.t( 'activerecord.errors.invalid_utf8_char', alphabeth: record.alphabeth_code,
               parts: '"' + parts.join('", "') + '"'))

Here we check if the parameters on a multi-line method call or definition are aligned.

Example: EnforcedStyle: withfirstparameter (default)

# good

foo :bar,
    :baz

# bad

foo :bar,
  :baz

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz

unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

      %i(year_date).include?(memo.errors.first&.attribute)
Severity: Minor
Found in app/services/calendary_copy.rb by rubocop

1 trailing blank lines detected.
Open

Severity: Minor
Found in lib/tasks/pry.rake by rubocop

unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

         icon_link&.valid? ? draw_iconed(title, desc, icon_link) : draw_plain(title, desc)
Severity: Minor
Found in app/services/pdf_book_service.rb by rubocop

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

         if o.keys.include?( :allow )

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?

Space found before semicolon.
Open

         I18n.t( 'activerecord.errors.invalid_patronymic' ) ; end ; end ; end

Checks for semicolon (;) preceded by space.

Example:

# bad
x = 1 ; y = 2

# good
x = 1; y = 2

end at 16, 61 is not aligned with if at 14, 6.
Open

         I18n.t( 'activerecord.errors.invalid_last_name' ) ; end ; end ; end

This cop checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

# good

puts(if true
end)

end at 11, 74 is not aligned with class at 1, 0.
Open

         I18n.t( 'activerecord.errors.invalid_patronymic' ) ; end ; end ; end

This cop checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

# good

puts(if true
end)
Severity
Category
Status
Source
Language