Showing 331 of 343 total issues
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if record.project
- 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
Freeze mutable objects assigned to constants. Open
CSV_HEADERS = [
"Id", "Story", "Labels", "Iteration", "Iteration Start", "Iteration End",
"Story Type", "Estimate", "Current State", "Started At", "Created at", "Accepted at",
"Deadline", "Requested By", "Owned By", "Description", "URL"
]
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
"Id", "Story", "Labels", "Iteration", "Iteration Start", "Iteration End",
- Exclude checks
Align .since
with where("subject_type in ('Project', 'Story')")
on line 28. Open
.since(since).to_a
- Exclude checks
Line is too long. [101/100] Open
# with calculate_worst = true add the standard deviation of the velocity for the past 10 iterations
- Exclude checks
Line is too long. [111/100] Open
std_dev = Statistics.standard_deviation(group_by_velocity.values, STD_DEV_ITERATIONS)
- 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
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
"Deadline", "Requested By", "Owned By", "Description", "URL"
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
"Deadline", "Requested By", "Owned By", "Description", "URL"
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
"Deadline", "Requested By", "Owned By", "Description", "URL"
- Exclude checks
Avoid the use of double negation (!!
). Open
!!archived_at
- 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.
Shadowing outer local variable - activities
. Open
activities.group_by(&:project_id).map do |project_id, activities|
- Read upRead up
- Exclude checks
This cop looks for use of the same name as outer local variables
for block arguments or block local variables.
This is a mimic of the warning
"shadowing outer local variable - foo" from ruby -cw
.
Example:
# bad
def some_method
foo = 1
2.times do |foo| # shadowing outer `foo`
do_something(foo)
end
end
Example:
# good
def some_method
foo = 1
2.times do |bar|
do_something(bar)
end
end
Do not freeze immutable objects, as freezing them has no effect. Open
DOMAIN_SEPARATORS_REGEX = /[,;\|\n]/.freeze
- Read upRead up
- Exclude checks
This cop check for uses of Object#freeze on immutable objects.
Example:
# bad
CONST = 1.freeze
# good
CONST = 1
Place the . on the next line, together with the method name. Open
group_by { |story| story.owned_by.name }.
- Exclude checks
Line is too long. [112/100] Open
number_of_iterations = group_by_all_iterations.size if number_of_iterations > group_by_all_iterations.size
- Exclude checks
Annotation keywords like FIXME
should be all upper case, followed by a colon, and a space, then a note describing the problem. Open
# FIXME must figure out why the Story allows a nil owner in delivered states
- Exclude checks
Place the . on the next line, together with the method name. Open
@backlog.
- Exclude checks
Space inside parentheses detected. Open
( days_apart / days_in_iteration ).floor + 1
- Exclude checks
Line is too long. [121/100] Open
accepted = accepted.select { |story| story.accepted_at >= range.first && story.accepted_at < range.last } if range
- 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)