Skip to content

Rails/HasManyOrHasOneDependent false positive when passing a scope #541

Closed
@francois-ferrandis

Description

Expected behavior

No offfence detected

Actual behavior

Rails/HasManyOrHasOneDependent is detected

Steps to reproduce the problem

Given this model:

class Message < ApplicationRecord
  has_many :comments, -> { order(:created_at) }, dependent: :destroy, inverse_of: :message
end

I get:

app/models/message.rb:2:3: C: Rails/HasManyOrHasOneDependent: Specify a :dependent option.
  has_many :comments, -> { order(:created_at) }, dependent: :destroy, inverse_of: :message
  ^^^^^^^^

RuboCop version

1.20.0 (using Parser 3.0.2.0, rubocop-ast 1.11.0, running on ruby 3.0.2 x86_64-linux)
  - rubocop-rails 2.12.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions