Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails/SaveBang: there's more than just persisted? #1151

Open
akimd opened this issue Oct 12, 2023 · 0 comments
Open

Rails/SaveBang: there's more than just persisted? #1151

akimd opened this issue Oct 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@akimd
Copy link

akimd commented Oct 12, 2023

Expected behavior

$ cat rails.rb
def destroy
  record = Record.find(params[:id])
  record.destroy
  @success = record.destroyed?
end

The call to destroy is checked. Yet Rails/SaveBang complains.

Actual behavior

$ bundle exec rubocop rails.rb
Inspecting 1 file
C

Offenses:

rails.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
def destroy
^
rails.rb:3:10: C: [Correctable] Rails/SaveBang: Use destroy! instead of destroy if the return value is not checked.
  record.destroy
         ^^^^^^^

1 file inspected, 2 offenses detected, 2 offenses autocorrectable

Steps to reproduce the problem

See above.

RuboCop version

$ bundle exec rubocop -V
1.56.3 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [arm64-darwin22]
  - rubocop-rails 2.21.2
@koic koic added the enhancement New feature or request label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants