Showing 331 of 343 total issues
Use find_by
instead of dynamic find_by_user_id
. Open
enrollments.find_by_user_id(user.id)&.is_admin?
- Read upRead up
- Exclude checks
This cop checks dynamic find_by_*
methods.
Use find_by
instead of dynamic method.
See. https://github.com/bbatsov/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)
Place the . on the next line, together with the method name. Open
select { |story| story.state == state }.
- Exclude checks
Pass &:iteration_number
as an argument to group_by
instead of a block. Open
group_by { |story| story.iteration_number }.
- Read upRead up
- Exclude checks
Use symbols as procs when possible.
Example:
# bad
something.map { |s| s.upcase }
# good
something.map(&:upcase)
Use !empty?
instead of size > 0
. Open
if iterations.size > 0
- Read upRead up
- Exclude checks
This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.
Example:
# bad
[1, 2, 3].length == 0
0 == "foobar".length
array.length < 1
{a: 1, b: 2}.length != 0
string.length > 0
hash.size > 0
# good
[1, 2, 3].empty?
"foobar".empty?
array.empty?
!{a: 1, b: 2}.empty?
!string.empty?
!hash.empty?
Trailing whitespace detected. Open
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
"Story Type", "Estimate", "Current State", "Started At", "Created at", "Accepted at",
- Exclude checks
Line is too long. [111/100] Open
story.project.suppress_notifications = true # otherwise the import will generate massive notifications!
- Exclude checks
Surrounding space missing for operator =>
. Open
:type=>'text/javascript'
- Exclude checks
Place the . on the next line, together with the method name. Open
@accepted_stories.
- Exclude checks
Place the . on the next line, together with the method name. Open
group_by { |story| story.iteration_number }.
- Exclude checks
Place the . on the next line, together with the method name. Open
select { |story| story.column != '#chilly_bin' }.
- Exclude checks
Unnecessary spacing detected. Open
accepted = accepted.select { |story| story.accepted_at >= range.first && story.accepted_at < range.last } if range
- Exclude checks
Align select
with @stories.
on line 20. Open
select { |story| story.column == '#done' }.
- Exclude checks
Align group_by
with @accepted_stories.
on line 106. Open
group_by { |story| story.iteration_number }.
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
@dummy_user ||= User.find_or_create_by!(username: "dummy", email: "dummy@foo.com", name: "Dummy", initials: "XX")
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if record.project && !value.nil?
- 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
Replace "central"
with 'central'
Open
import ProjectsShowController from "central";
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace "libs"
with 'libs'
Open
import "libs";
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace "beta/projects.show"
with 'beta/projects.show'
Open
"beta/projects.show": BetaShowProjectBoardController,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace "controllers/projects/IndexController"
with 'controllers/projects/IndexController'
Open
import ProjectsIndexController from "controllers/projects/IndexController";
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/