A RuboCop extension focused on enforcing Rails best practices and coding conventions.
MIT License
Bot releases are hidden (Show)
Rails/WhereRange
cop. (@fatkodima)Rails/Validation
when using validates_size_of
. (@koic)Rails/SkipsModelValidations
when using insert
or insert!
with a safe navigator. (@tldn0718)Rails/UnknownEnv
when using Rails 7.1. (@lukasfroehlich1)Rails/UnusedIgnoredColumns
by default. (@earlopain)change_table
calls for offenses. (@ccutrer)Rails/HttpStatus
aware of Rails-specific response assertions. (@tldn0718)TargetRailsVersion
the new requires_gem
API. (@amomchilov)Published by koic 7 months ago
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)Published by koic 8 months ago
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)Published by koic 10 months ago
Rails/WhereNot
when calling .where
on an implicit receiver (e.g. inside model code). (@bquorning)Published by koic 10 months ago
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)Published by koic 11 months ago
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)Published by koic 12 months ago
Published by koic 12 months ago
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)Published by koic about 1 year ago
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)Published by koic about 1 year ago
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)Published by koic about 1 year ago
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)Published by koic over 1 year ago
Published by koic over 1 year ago
Published by koic over 1 year ago
Rails/Date
. (@r7kamura)Rails/FilePath
. (@r7kamura)Rails/IgnoredSkipActionFilterOption
. (@r7kamura)break
in with_lock
for Rails/TransactionExitStatement
. (@splattael)NotNullColumn
to work with method calls and variables. (@fidalgo)Rails/FilePath
to detect offenses from complex string interpolation. (@r7kamura)Rails/ThreeStateBooleanColumn
for dynamic tables/columns. (@fatkodima)UniqueValidationWithoutIndex
to not detect offenses when a validation specifies uniqueness: false
. (@samrjenkins)*_create_active_storage_variant_records.active_storage.rb
to Rails/CreateTableWithTimestamps
exclude file list. (@tka5)or
method in Rails/FindEach
cop. (@masato-bkn)app/assets/**/*
by default. (@r7kamura)Lint/RedundantSafeNavigation
aware of presence
and present?
methods. (@koic)flash.now
for Rails/I18nLocaleTexts
. (@fatkodima)Published by koic over 1 year ago
Published by koic over 1 year ago
Rails/ThreeStateBooleanColumn
cop. (@fatkodima)Rails/Delegate
aware of self
. (@koic)Rails/Output
when print methods without arguments. (@koic)Rails/HttpPositionalArguments
when using include Rack::Test::Methods
. (@koic)Rails/OutputSafety
when using html_safe
for I18n
methods. (@koic)Rails/Pluck
when using regexp literal key for String#[]
. (@koic)Rails/WhereNotWithMultipleConditions
when using where.not.lt(condition)
as a Mongoid API'. (@koic)Style/InverseMethods
. (@koic)Published by koic over 1 year ago
Rails/ActionControllerTestCase
when the class is namespaced. (@vlad-pisanov)Rails/ActionControllerFlashBeforeRender
when using flash
before redirect_to
in if
branch. (@koic)Rails/ActiveRecordAliases
when arguments of update_attributes
is empty. (@koic)Rails/NegateInclude
when there is no receiver. (@fatkodima)Rails/Presence
when ternary operators are used in multiple lines. (@r7kamura)Rails/HasManyOrHasOneDependent
to correctly handle association methods with receiver. (@fatkodima)Rails/SquishedSQLHeredocs
applying when single-line comments are present. (@john-h-k)Rails/NotNullColumn
when adding a :virtual
column. (@fatkodima)Rails/FreezeTime
running against Rails < 5.2 apps. (@DRBragg)Rails/UnusedIgnoredColumns
not recognizing columns added via +=
. (@lucthev)alias
in Rails/LexicallyScopedActionFilter
. (@fatkodima)redirect
method for Style/FormatStringToken
by default. (@javierjulio)Style/InverseMethods
aware of Active Support's present?
, blank?
, include?
, and exclude?
methods. (@koic)Style/InverseMethods
aware of valid?
and invalid?
methods. (@koic)Rails/Pluck
as unsafe. (@fatkodima)Rails/ActiveRecordOverride
, Rails/DeprecatedActiveModelErrorsMethods
, Rails/DuplicateAssociation
, Rails/DuplicateScope
, Rails/TopLevelHashWithIndifferentAccess
, and Rails/WhereNotWithMultipleConditions
cops to warning. (@koic)Published by koic almost 2 years ago
Rails/RootPathnameMethods
when using Rails.env
argument within Dir.glob
. (@koic)Rails/ActionControllerFlashBeforeRender
when using flash
in multiline rescue
branch before redirect_to
. (@gurix)Rails/WhereMissing
when left_joins(:foo)
and where(foos: {id: nil})
separated by or
, and
. (@ydah)Rails/RootPathnameMethods
aware of enforced style of Style/StringLiterals
. (@koic)Rails/UniqueValidationWithoutIndex
with :conditions option. (@etiennebarrie)Rails/TimeZone
to accept methods with the :in
timezone option. (@fatkodima)Published by koic almost 2 years ago
% cat relnotes/v2.17.3.md
Rails/ActionControllerFlashBeforeRender
when using flash
in multiline if
branch before redirect_to
. (@koic)Rails/ActionOrder
when using unconventional order of multiple actions. (@koic)Rails/ActionOrder
when using unconventional order of actions in conditions. (@koic)::Hash
is used on Rails/IndexBy
and Rails/IndexWith
. (@r7kamura)Rails/FreezeTime
when using travel_to
with an argument of Time.new(...).in_time_zone
. (@koic)Rails/ToSWithArgument
. (@r7kamura)Rails/DurationArithmetic
, Rails/IndexBy
, Rails/IndexWIth
, and Rails/RequireDependency
. (@r7kamura)Rails/I18nLazyLookup
. (@vlad-pisanov)Rails/ActionOrder
about comments. (@r7kamura)::
prefixed constants on Rails/ActionControllerFlashBeforeRender
, Rails/ActionControllerTestCase
, Rails/ApplicationController
, Rails/ApplicationJob
, Rails/ApplicationMailer
, Rails/ApplicationRecord
, Rails/DotSeparatedKeys
, Rails/DynamicFindBy
, Rails/FindEach
, Rails/FreezeTime
, Rails/HasManyOrHasOneDependent
, Rails/HelperInstanceVariable
, Rails/MailerName
, Rails/MigrationClassName
, Rails/Output
, Rails/ReversibleMigrationMethodDefinition
, Rails/ReversibleMigration
, Rails/ShortI18n
, Rails/SkipsModelValidations
, and Rails/TimeZoneAssignment
. (@r7kamura)::Rails
and ::File
on Rails/FilePath
cop. (@r7kamura)Published by koic almost 2 years ago
Rails/ActionControllerFlashBeforeRender
when using condition before redirect_to
. (@koic)Rails/Pluck
when receiver is not block argument for []
. (@koic)Rails/WhereNotWithMultipleConditions
when using where.not
with empty hash literal. (@koic)Rails/Pluck
when using multiple block arguments. (@koic)