Block has too many lines. [55/25] Open
ActiveAdmin.register Delayed::Job, as: "Job" do
actions :index, :show, :edit, :update, :destroy
index do
column :id
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Avoid using update_attribute
because it skips validations. Open
resource.update_attribute :attempts, 0
- Read upRead up
- Exclude checks
This cop checks for the use of methods which skip validations which are listed in http://guides.rubyonrails.org/active_record_validations.html#skipping-validations
Example:
# bad
Article.first.decrement!(:view_count)
DiscussionBoard.decrement_counter(:post_count, 5)
Article.first.increment!(:view_count)
DiscussionBoard.increment_counter(:post_count, 5)
person.toggle :active
product.touch
Billing.update_all("category = 'authorized', author = 'David'")
user.update_attribute(website: 'example.com')
user.update_columns(last_request_at: Time.current)
Post.update_counters 5, comment_count: -1, action_count: 1
# good
user.update_attributes(website: 'example.com')
FileUtils.touch('file')
Align the elements of a hash literal if they span more than one line. Open
title: "Cause a job scheduled in the future to run now."
- Read upRead up
- Exclude checks
Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:
- key (left align keys)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)
The treatment of hashes passed as the last argument to a method call can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
- ignore_explicit (with curly braces)
Example:
# EnforcedHashRocketStyle: key (default)
# EnforcedColonStyle: key (default)
# good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
# bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
Example:
# EnforcedHashRocketStyle: separator
# EnforcedColonStyle: separator
#good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
#bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
Example:
# EnforcedHashRocketStyle: table
# EnforcedColonStyle: table
#good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
#bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
Align the elements of a hash literal if they span more than one line. Open
title: "Resets the state caused by errors. Lets a worker give it another go ASAP."
- Read upRead up
- Exclude checks
Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:
- key (left align keys)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)
The treatment of hashes passed as the last argument to a method call can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
- ignore_explicit (with curly braces)
Example:
# EnforcedHashRocketStyle: key (default)
# EnforcedColonStyle: key (default)
# good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
# bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
Example:
# EnforcedHashRocketStyle: separator
# EnforcedColonStyle: separator
#good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
#bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
Example:
# EnforcedHashRocketStyle: table
# EnforcedColonStyle: table
#good
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
#bad
{
foo: bar,
ba: baz
}
{
:foo => bar,
:ba => baz
}
Use %i
or %I
for an array of symbols. Open
action_item :schedule, only: [:show, :edit] do
- Read upRead up
- Exclude checks
This cop can check for array literals made up of symbols that are not using the %i() syntax.
Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize of
3` will not enforce a style on an array
of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%i[foo bar baz]
# bad
[:foo, :bar, :baz]
Example: EnforcedStyle: brackets
# good
[:foo, :bar, :baz]
# bad
%i[foo bar baz]
Use %i
or %I
for an array of symbols. Open
action_item :reset, only: [:show, :edit] do
- Read upRead up
- Exclude checks
This cop can check for array literals made up of symbols that are not using the %i() syntax.
Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize of
3` will not enforce a style on an array
of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%i[foo bar baz]
# bad
[:foo, :bar, :baz]
Example: EnforcedStyle: brackets
# good
[:foo, :bar, :baz]
# bad
%i[foo bar baz]