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 99
1010## master (unreleased)
1111
12+ ## 2.33.3 (2025-08-14)
13+
1214### Bug fixes
1315
1416* [ #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
22title : RuboCop Rails
33# We always provide version without patch here (e.g. 1.1),
44# as patch versions should not appear in the docs.
5- version : ~
5+ version : ' 2.33 '
66nav :
77 - 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.
26372637
26382638[source,ruby]
26392639----
2640- # bad
2640+ # bad - exclusively doing memoization
26412641def current_user
26422642 @current_user ||= User.find_by(id: session[:user_id])
26432643end
@@ -2648,6 +2648,22 @@ def current_user
26482648
26492649 @current_user = User.find_by(id: session[:user_id])
26502650end
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
26512667----
26522668
26532669[#references-railsfindbyorassignmentmemoization]
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ module RuboCop
44 module Rails
55 # This module holds the RuboCop Rails version information.
66 module Version
7- STRING = '2.33.2 '
7+ STRING = '2.33.3 '
88
99 def self . document_version
1010 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