Showing 439 of 439 total issues
Use find_by
instead of dynamic find_by_uid_and_provider
. Open
user = find_by_uid_and_provider
- Read upRead up
- Exclude checks
This cop checks dynamic find_by_*
methods.
Use find_by
instead of dynamic method.
See. https://github.com/rubocop-hq/rails-style-guide#find_by
Example:
# bad
User.find_by_name(name)
# bad
User.find_by_name_and_email(name)
# bad
User.find_by_email!(name)
# good
User.find_by(name: name)
# good
User.find_by(name: name, email: email)
# good
User.find_by!(email: email)
Line is too long. [143/100] Open
gem 'spring' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
- Exclude checks
Specify a :dependent
option. Open
has_many :events, class_name: 'Ahoy::Event'
- Read upRead up
- Exclude checks
This cop looks for has_many
or has_one
associations that don't
specify a :dependent
option.
It doesn't register an offense if :through
option was specified.
Example:
# bad
class User < ActiveRecord::Base
has_many :comments
has_one :avatar
end
# good
class User < ActiveRecord::Base
has_many :comments, dependent: :restrict_with_exception
has_one :avatar, dependent: :destroy
has_many :patients, through: :appointments
end
Missing magic comment # frozen_string_literal: true
. Open
# == Schema Information
- Read upRead up
- Exclude checks
This cop is designed to help you transition from mutable string literals
to frozen string literals.
It will add the comment # frozen_string_literal: true
to the top of
files to enable frozen string literals. Frozen string literals may be
default in future Ruby. The comment will be added below a shebang and
encoding comment. The frozen string literal comment is only valid in
Ruby 2.3+.
Note that the cop will ignore files where the comment exists but is set
to false
instead of true
.
Example: EnforcedStyle: always (default)
# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
# ...
end
# good
# frozen_string_literal: true
module Bar
# ...
end
# good
# frozen_string_literal: false
module Bar
# ...
end
Example: EnforcedStyle: never
# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true
module Baz
# ...
end
# good
module Baz
# ...
end
Line is too long. [101/100] Open
Ahoy::Event.cached_any_events_for?(Ahoy::Event::LIKED_DESIGN, current_user, design_id: design_id)
- Exclude checks
Use a guard clause (return unless current_user
) instead of wrapping the code inside a conditional expression. Open
if current_user
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Avoid the use of double negation (!!
). Open
gem 'bullet', '~> 5.9', require: !!ENV['ENABLE_BULLET'] # n+1 Queries
- Read upRead up
- Exclude checks
This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.
Example:
# bad
!!something
# good
!something.nil?
Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.
Commas in function arguments should be followed by one space Open
box-shadow: 0 0 2rem 0 rgba(136,152,170,.15);
- Exclude checks
Commas in function arguments should be followed by one space Open
border-bottom: 1px solid rgba(0,0,0,.05);
- Exclude checks
Line should be indented 2 spaces, but was indented 4 spaces Open
flex-wrap: wrap;
- Exclude checks
Merge rule .inline-list li:last-child
with rule on line 55 Open
.inline-list li:last-child {
- Exclude checks
Properties should be ordered bottom, content, display, left, position, top, width Open
content: '';
- Exclude checks
Properties should be ordered height, line-height, min-width, text-indent Open
min-width: calc(#{$switch-height-sm} * 2);
- Exclude checks
Colon after property should be followed by one space Open
background:#b4b4b4;
- Exclude checks
Color literals like #e2e6ea
should only be used in variable declarations; they should be referred to via variable everywhere else. Open
background-color: #e2e6ea;
- Exclude checks
Rule declaration should be followed by an empty line Open
}
- Exclude checks
Properties should be ordered background, border-radius, color, display, line-height, overflow, position Open
display: flex;
- Exclude checks
Prefer single quoted strings Open
content: "\f382";
- Exclude checks
Avoid qualifying attribute selectors with an element. Open
div[class^="validation-"], div[class$="-feedback"] {
- Exclude checks
Properties should be ordered background-color, border-color, color Open
color: $white;
- Exclude checks