Skip to content

Cop idea: Ensure the correct usage of prepend: true in before_destroy callbacks. #1083

@ydakuka

Description

@ydakuka

Reference: https://rails.rubystyle.guide/#before_destroy

Actual behavior

I have the code:

# frozen_string_literal: true class User < ApplicationRecord has_many :roles, dependent: :destroy before_destroy :ensure_deletable def ensure_deletable raise 'Cannot delete super admin.' if super_admin? end end

I will run rubocop and not get any offences:

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop app/models/user.rb Inspecting 1 file . 1 file inspected, no offenses detected

Rubocop

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop -V 1.55.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 2.7.8) [x86_64-linux] - rubocop-capybara 2.18.0 - rubocop-factory_bot 2.23.1 - rubocop-performance 1.18.0 - rubocop-rails 2.20.2 - rubocop-rake 0.6.0 - rubocop-rspec 2.23.0 - rubocop-thread_safety 0.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions