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 is issuing warning regardless of the actual type on the receiver #1154

Open
akimd opened this issue Oct 13, 2023 · 1 comment

Comments

@akimd
Copy link

akimd commented Oct 13, 2023

Hi there!

Expected behavior

This is obviously not an ActiveRecord instance, the update is fine as it is.

$ cat save.rb
h = {a: 1}
h.update(b: 1, c: 2)

Actual behavior

$ bundle exec rubocop save.rb
Inspecting 1 file
C

Offenses:

save.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
h = {a: 1}
^
save.rb:2:3: C: [Correctable] Rails/SaveBang: Use update! instead of update if the return value is not checked.
h.update(b: 1, c: 2)
  ^^^^^^

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
@krystof-k
Copy link

krystof-k commented Apr 16, 2024

I'm facing probably similar issue when using Stripe gem, which uses methods like .create, e.g.:

Stripe::Customer.create({
  name: 'Jenny Rosen',
  email: 'jennyrosen@example.com',
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants