Skip to content

Commit 2e782c7

Browse files
committed
Remove useless unless node type
1 parent 7ff8317 commit 2e782c7

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

lib/rubocop/cop/rails/find_by_or_assignment_memoization.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class FindByOrAssignmentMemoization < Base
4343
def on_send(node)
4444
assignment_node = node.parent
4545
find_by_or_assignment_memoization(assignment_node) do |varible_name, find_by|
46-
next if in_condition?(assignment_node)
46+
next if assignment_node.each_ancestor(:if).any?
4747

4848
add_offense(assignment_node) do |corrector|
4949
corrector.replace(
@@ -59,12 +59,6 @@ def on_send(node)
5959
end
6060
end
6161
end
62-
63-
private
64-
65-
def in_condition?(node)
66-
node.each_ancestor(:if, :unless).any?
67-
end
6862
end
6963
end
7064
end

lib/rubocop/cop/rails/redundant_presence_validation_on_belongs_to.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class RedundantPresenceValidationOnBelongsTo < Base
7474
$[
7575
(hash <$(pair (sym :presence) true) ...>) # presence: true
7676
!(hash <$(pair (sym :strict) {true const}) ...>) # strict: true
77-
!(hash <$(pair (sym {:if :unless}) _) ...>) # if: some_condition or unless: some_condition
77+
!(hash <$(pair (sym {:if}) _) ...>) # if: some_condition or unless: some_condition
7878
]
7979
)
8080
PATTERN

0 commit comments

Comments
 (0)