rubocop-rails 2.33.1 → 2.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf236bb6f7b10ea743c3afd8b4c92f2563d5cd989f3c8820b8fb270c9bb72c59
|
4
|
+
data.tar.gz: 356c8e006d8e4d1b4893cb263b9a67e0ecc3245556868678c5681800cc75cf36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fbcfbc453e83a19e6b9c1b173347c9dbef375650c4202ac7949fcec04ae8bc65307246d0630a106455cb44a66e3736d287894e4709b12692fd6e589ed574235
|
7
|
+
data.tar.gz: 245d221771ce84010ff4195efbb6c231e28e0daac18288d52c201b347951475ef29168098d518fe7d75f7a33524b5a90f81b604720ab130629651d598e23cec5
|
@@ -20,11 +20,9 @@ module RuboCop
|
|
20
20
|
#
|
21
21
|
# # good
|
22
22
|
# def current_user
|
23
|
-
# if
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# @current_user = User.find_by(id: session[:user_id])
|
27
|
-
# end
|
23
|
+
# return @current_user if defined?(@current_user)
|
24
|
+
#
|
25
|
+
# @current_user = User.find_by(id: session[:user_id])
|
28
26
|
# end
|
29
27
|
class FindByOrAssignmentMemoization < Base
|
30
28
|
extend AutoCorrector
|
@@ -49,11 +47,9 @@ module RuboCop
|
|
49
47
|
corrector.replace(
|
50
48
|
assignment_node,
|
51
49
|
<<~RUBY.rstrip
|
52
|
-
if
|
53
|
-
|
54
|
-
|
55
|
-
#{varible_name} = #{find_by.source}
|
56
|
-
end
|
50
|
+
return #{varible_name} if defined?(#{varible_name})
|
51
|
+
|
52
|
+
#{varible_name} = #{find_by.source}
|
57
53
|
RUBY
|
58
54
|
)
|
59
55
|
end
|
@@ -66,7 +66,7 @@ module RuboCop
|
|
66
66
|
return false unless enclosing_method
|
67
67
|
|
68
68
|
shadowing_method_name = first_arg.value.to_s
|
69
|
-
shadowing_method_name
|
69
|
+
shadowing_method_name += '=' if node.method?(:write_attribute)
|
70
70
|
enclosing_method.method?(shadowing_method_name)
|
71
71
|
end
|
72
72
|
|