File tree Expand file tree Collapse file tree 5 files changed +26
-3
lines changed Expand file tree Collapse file tree 5 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 9
9
10
10
## master (unreleased)
11
11
12
+ ## 2.33.3 (2025-08-14)
13
+
12
14
### Bug fixes
13
15
14
16
* [ #1516 ] ( https://github.com/rubocop/rubocop-rails/pull/1516 ) : Fix wrong autocorrect for ` Rails/FindByOrAssignmentMemoization ` . ([ @earlopain ] [ ] )
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ name: rubocop-rails
2
2
title : RuboCop Rails
3
3
# We always provide version without patch here (e.g. 1.1),
4
4
# as patch versions should not appear in the docs.
5
- version : ~
5
+ version : ' 2.33 '
6
6
nav :
7
7
- modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change @@ -2637,7 +2637,7 @@ or the code may have a different purpose than memoization.
2637
2637
2638
2638
[source,ruby]
2639
2639
----
2640
- # bad
2640
+ # bad - exclusively doing memoization
2641
2641
def current_user
2642
2642
@current_user ||= User.find_by(id: session[:user_id])
2643
2643
end
@@ -2648,6 +2648,22 @@ def current_user
2648
2648
2649
2649
@current_user = User.find_by(id: session[:user_id])
2650
2650
end
2651
+
2652
+ # bad - method contains other code
2653
+ def current_user
2654
+ @current_user ||= User.find_by(id: session[:user_id])
2655
+ @current_user.do_something
2656
+ end
2657
+
2658
+ # good
2659
+ def current_user
2660
+ if defined?(@current_user)
2661
+ @current_user
2662
+ else
2663
+ @current_user = User.find_by(id: session[:user_id])
2664
+ end
2665
+ @current_user.do_something
2666
+ end
2651
2667
----
2652
2668
2653
2669
[#references-railsfindbyorassignmentmemoization]
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ module RuboCop
4
4
module Rails
5
5
# This module holds the RuboCop Rails version information.
6
6
module Version
7
- STRING = '2.33.2 '
7
+ STRING = '2.33.3 '
8
8
9
9
def self . document_version
10
10
STRING . match ( '\d+\.\d+' ) . to_s
Original file line number Diff line number Diff line change
1
+ ### Bug fixes
2
+
3
+ * [ #1516 ] ( https://github.com/rubocop/rubocop-rails/pull/1516 ) : Fix wrong autocorrect for ` Rails/FindByOrAssignmentMemoization ` . ([ @earlopain ] [ ] )
4
+
5
+ [ @earlopain ] : https://github.com/earlopain
You can’t perform that action at this time.
0 commit comments