A RuboCop extension focused on enforcing Rails best practices and coding conventions.
Rails/ActionControllerFlashBeforeRender
when returning redirect_to
. (@earlopain)Rails/UniqBeforePluck
with EnforcedStyle: aggressive
when no receiver. (@earlopain)Rails/UnusedIgnoredColumns
when without tables in db/schema.rb. (@koic)Rails/WhereMissing
with leading where
without receiver. (@earlopain)Rails/ExpandedDateRange
when passing an argument only to the first method call for weeks. (@earlopain)Rails/ActiveSupportOnLoad
when calling without arguments. (@earlopain)Rails/SaveBang
if persisted?
is checked on parenthesised expression. (@earlopain)Rails/TimeZone
aware of safe navigation. (@earlopain)active_record_sqlite3adapter
to Rails/ActiveSupportOnLoad
. (@earlopain)Rails/FindBy
when using multi-line leading dot method calls. (@ymap)Rails/WhereExists
with EnforcedStyle: where
and implicit receivers. (@earlopain)Rails/EnvironmentVariableAccess
aware of initializers. (@markokajzer)object_id
from Rails/DangerousColumnNames
targets. (@r7kamura)Rails/WhereNot
when calling .where
on an implicit receiver (e.g. inside model code). (@bquorning)Rails/WhereMissing
where join method is called without arguments. (@fatkodima)Rails/Pluck
when using safe navigation method calls. (@koic)Rails/ActiveSupportAliases
, Rails/FindBy
, Rails/FindById
, Rails/Inquiry
, Rails/Pick
Rails/PluckId
, Rails/PluckInWhere
, Rails/WhereEquals
, Rails/WhereExists
, and Rails/WhereNot
cops aware of safe navigation operator. (@koic)Rails/PluckInWhere
to check for .ids
call. (@fatkodima)Nokogiri::HTML.parse
and Nokogiri::HTML5.parse
on Rails/ResponseParsedBody
. (@r7kamura)where.not
for Rails/PluckInWhere
. (@fatkodima)Rails/UnknownEnv
when using Rails 7.1. (@koic)Rails/RedundantActiveRecordAllMethod
cop when used with RuboCop 1.51 or lower. (@koic)Rails/RedundantActiveRecordAllMethod
to ignore delete_all
and destroy_all
when receiver is an association. (@masato-bkn)Rails/EnvLocal
cop. (@sambostock)Rails/DuplicateAssociation
aware of duplicate class_name
. (@koic)Rails/RedundantActiveRecordAllMethod
. (@koic)Rails/NotNullColumn
when using null: false
for MySQL's TEXT type. (@koic)Rails/Output
when output method is called with block argument. (@koic)Rails/RedundantActiveRecordAllMethod
when using RuboCop 1.51 or lower. (@koic)Rails/RedundantPresenceValidationOnBelongsTo
when using validates
with :if
or :unless
options. (@koic)Rails/HasManyOrHasOneDependent
does not add offence when has_many or has_one is called on an explicit receiver. (@samrjenkins)Rails/SaveBang
to ignore parenthesis. (@fatkodima)Rails/RedundantActiveRecordAllMethod
when using some Enumerable
's methods with block argument. (@koic)Rails/SelectMap
when using select(:column_name).map(&:column_name)
without receiver model. (@koic)Rails/RedundantActiveRecordAllMethod
when all
has parentheses. (@masato-bkn)Rails/UniqueValidationWithoutIndex
with bare validate. (@jamiemccarthy)Rails/RedundantActiveRecordAllMethod
when receiver is not an Active Record model. (@koic)Rails/TimeZone
when using String#to_time
. (@koic)Rails/RedundantActiveRecordAllMethod
when all
is an argument for AR methods. (@masato-bkn)Rails/RedundantActiveRecordAllMethod
when all
has any parameters. (@masato-bkn)Rails/SelectMap
cop that checks for uses of select(:column_name)
with map(&:column_name)
. (@koic)Rails/DangerousColumnNames
cop. (@r7kamura)TransactionMethods
config for Rails/TransactionExitStatement
to detect custom transaction methods. (@marocchino)Rails/UnusedRenderContent
cop. (@samrjenkins)Rails/I18nLazyLookup
. (@sunny)Rails/RedundantActiveRecordAllMethod
cop. (@masato-bkn)Rails/LexicallyScopedActionFilter
when no methods are defined. (@vlad-pisanov)Rails/HttpStatus
when using symbolic value that have no numeric value mapping. (@koic)Rails/RootPathnameMethods
on Ruby 2.4 or lower. (@r7kamura)Rails/FilePath
when string interpolated Rails.root
is followed by a message starting with .
. (@koic)Rails/FilePath
when File.join with Rails.root and path starting with /
. (@ydah)Rails/NegateInclude
when using Style/InverseMethods
's autocorrection together. (@koic)Rails/RakeEnvironment
when rake task accepts arguments. (@fastjames)UniqueValidationWithoutIndex
when db/schema.rb
is empty. (@fatkodima)Rails/SchemaComment
when create_table with multi t columns. (@nipe0324)Lint/SafeNavigationChain
allow presence_in
. (@koic)Rails/HttpStatus
aware of string number status. (@r7kamura)Rails/TimeZone
aware of String#to_time
. (@koic)Style/InvertibleUnlessCondition
aware of Active Support methods. (@koic)Rails/BulkChangeTable
from environment variable. (@joergschiller)Include
path for Rails/FindBy
and Rails/FindEach
. (@koic)