You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have identified a potential issue in the behavior of Rubocop regarding the detection of identical has_many definitions in an ActiveRecord model. When two has_many associations have different names but share identical options, such as class_name, Rubocop fails to raise an offense, which it should.
in rails, there is one exception when has_many method has lambda then Rubocop should NOT add offense see example has_many :comments, -> { pending }, class_name: 'Main::Comment'
Steps to Reproduce:
Create an ActiveRecord model with two has_many associations using different names but sharing identical options, such as class_name.
I have identified a potential issue in the behavior of Rubocop regarding the detection of identical has_many definitions in an ActiveRecord model. When two has_many associations have different names but share identical options, such as class_name, Rubocop fails to raise an offense, which it should.
Steps to Reproduce:
Create an ActiveRecord model with two has_many associations using different names but sharing identical options, such as class_name.
Example:
Expected Result:
Rubocop should raise an offense indicating that there are identical has_many definitions with the same options.
Actual Result:
Rubocop does not raise any offense for these identical has_many definitions, even though they should be detected as a potential issue.
Additional info:
rubocop-rails (2.21.1)
cop name:
Rails/DuplicateAssociation
The text was updated successfully, but these errors were encountered: