Showing 12,628 of 12,628 total issues
unexpected token tCONSTANT
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
created.push LoanItem.create!(loan_item_object: o.tag_object, loan_id:)
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
unexpected token tCOMMA
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
klass.constantize.joins(:pinboard_items).where(pinboard_items: {user_id:, project_id:, pinned_object_type: klass}).each do |o|
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
unexpected token tRCURLY
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
.where(g: {id:})
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
Use 2 (not 4) spaces for indentation. Open
validate :source_use_only
- Read upRead up
- Exclude checks
This cop 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 tRCURLY
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
.where(i: {id:})
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
unexpected token tRPAREN
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
h[:recent] = Image.where(project_id:).order('updated_at DESC').limit(10).to_a
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
cannot assign to a keyword
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
type: nil, # will be protonym or combination
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
Prefer 1.month
. Open
.where(t['updated_at'].gt( 1.months.ago ))
- Read upRead up
- Exclude checks
This cop checks for correct grammar when using ActiveSupport's core extensions to the numeric classes.
Example:
# bad
3.day.ago
1.months.ago
# good
3.days.ago
1.month.ago
Prefer 1.month
. Open
.where(t['updated_at'].gt( 1.months.ago ))
- Read upRead up
- Exclude checks
This cop checks for correct grammar when using ActiveSupport's core extensions to the numeric classes.
Example:
# bad
3.day.ago
1.months.ago
# good
3.days.ago
1.month.ago
unexpected token tASSOC
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
rescue ActiveRecord::RecordInvalid => e
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
unexpected token tRPAREN
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
created.push LoanItem.create!(loan_item_object: o.pinned_object, loan_id:)
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
Redundant receiver in with_options
. Open
l.validate :size_of_total
- Read upRead up
- Exclude checks
This cop checks for redundant receiver in with_options
.
Receiver is implicit from Rails 4.2 or higher.
Example:
# bad
class Account < ApplicationRecord
with_options dependent: :destroy do |assoc|
assoc.has_many :customers
assoc.has_many :products
assoc.has_many :invoices
assoc.has_many :expenses
end
end
# good
class Account < ApplicationRecord
with_options dependent: :destroy do
has_many :customers
has_many :products
has_many :invoices
has_many :expenses
end
end
Example:
# bad
with_options options: false do |merger|
merger.invoke(merger.something)
end
# good
with_options options: false do
invoke(something)
end
# good
client = Client.new
with_options options: false do |merger|
client.invoke(merger.something, something)
end
# ok
# When `with_options` includes a block, all scoping scenarios
# cannot be evaluated. Thus, it is ok to include the explicit
# receiver.
with_options options: false do |merger|
merger.invoke
with_another_method do |another_receiver|
merger.invoke(another_receiver)
end
end
Use taxon_name.name.present?
instead of !taxon_name.name.blank?
. Open
taxon_name.errors.add(:name, 'name must be at least two letters') unless !taxon_name.name.blank? && taxon_name.name.length > 1
- Read upRead up
- Exclude checks
This cop checks for code that can be written with simpler conditionals
using Object#present?
defined by Active Support.
Interaction with Style/UnlessElse
:
The configuration of NotBlank
will not produce an offense in the
context of unless else
if Style/UnlessElse
is inabled. This is
to prevent interference between the auto-correction of the two cops.
Example: NotNilAndNotEmpty: true (default)
# Converts usages of `!nil? && !empty?` to `present?`
# bad
!foo.nil? && !foo.empty?
# bad
foo != nil && !foo.empty?
# good
foo.present?
Example: NotBlank: true (default)
# Converts usages of `!blank?` to `present?`
# bad
!foo.blank?
# bad
not foo.blank?
# good
foo.present?
Example: UnlessBlank: true (default)
# Converts usages of `unless blank?` to `if present?`
# bad
something unless foo.blank?
# good
something if foo.present?
Use taxon_name.name.present?
instead of !taxon_name.name.blank?
. Open
taxon_name.errors.add(:name, 'name must be capitalized') unless !taxon_name.name.blank? && taxon_name.name == taxon_name.name.capitalize
- Read upRead up
- Exclude checks
This cop checks for code that can be written with simpler conditionals
using Object#present?
defined by Active Support.
Interaction with Style/UnlessElse
:
The configuration of NotBlank
will not produce an offense in the
context of unless else
if Style/UnlessElse
is inabled. This is
to prevent interference between the auto-correction of the two cops.
Example: NotNilAndNotEmpty: true (default)
# Converts usages of `!nil? && !empty?` to `present?`
# bad
!foo.nil? && !foo.empty?
# bad
foo != nil && !foo.empty?
# good
foo.present?
Example: NotBlank: true (default)
# Converts usages of `!blank?` to `present?`
# bad
!foo.blank?
# bad
not foo.blank?
# good
foo.present?
Example: UnlessBlank: true (default)
# Converts usages of `unless blank?` to `if present?`
# bad
something unless foo.blank?
# good
something if foo.present?
Prefer the new style validations validates :column, presence: value
over validates_presence_of
. Open
validates_presence_of :type # not required, it's STI
- Read upRead up
- Exclude checks
This cop checks for the use of old-style attribute validation macros.
Example:
# bad
validates_acceptance_of :foo
validates_confirmation_of :foo
validates_exclusion_of :foo
validates_format_of :foo
validates_inclusion_of :foo
validates_length_of :foo
validates_numericality_of :foo
validates_presence_of :foo
validates_absence_of :foo
validates_size_of :foo
validates_uniqueness_of :foo
# good
validates :foo, acceptance: true
validates :foo, confirmation: true
validates :foo, exclusion: true
validates :foo, format: true
validates :foo, inclusion: true
validates :foo, length: true
validates :foo, numericality: true
validates :foo, presence: true
validates :foo, absence: true
validates :foo, size: true
validates :foo, uniqueness: true
Prefer the new style validations validates :column, uniqueness: value
over validates_uniqueness_of
. Open
validates_uniqueness_of :descriptor_id, scope: [:presence, :observation_object_id, :observation_object_type], message: 'the observation already exists'
- Read upRead up
- Exclude checks
This cop checks for the use of old-style attribute validation macros.
Example:
# bad
validates_acceptance_of :foo
validates_confirmation_of :foo
validates_exclusion_of :foo
validates_format_of :foo
validates_inclusion_of :foo
validates_length_of :foo
validates_numericality_of :foo
validates_presence_of :foo
validates_absence_of :foo
validates_size_of :foo
validates_uniqueness_of :foo
# good
validates :foo, acceptance: true
validates :foo, confirmation: true
validates :foo, exclusion: true
validates :foo, format: true
validates :foo, inclusion: true
validates :foo, length: true
validates :foo, numericality: true
validates :foo, presence: true
validates :foo, absence: true
validates :foo, size: true
validates :foo, uniqueness: true
Use find_each
instead of each
. Open
klass.constantize.joins(:tags).where(tags: {keyword_id: keyword_id } ).each do |o|
- Read upRead up
- Exclude checks
This cop is used to identify usages of all.each
and
change them to use all.find_each
instead.
Example:
# bad
User.all.each
# good
User.all.find_each
unexpected token tCOMMA
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
created.push ObservationMatrixRowItem::Single.create!(observation_matrix_id:, observation_object: o)
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
unexpected token tCOMMA
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Tag.where(keyword_id:, tag_object_type: OBSERVABLE_TYPES).all,
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.
unexpected token tNL
(Using Ruby 2.4 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
observation_matrix_id
)
- Read upRead up
- Exclude checks
This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.