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

False positives on "check 'save' return value" #400

Open
hakanai opened this issue Feb 15, 2023 · 0 comments
Open

False positives on "check 'save' return value" #400

hakanai opened this issue Feb 15, 2023 · 0 comments

Comments

@hakanai
Copy link

hakanai commented Feb 15, 2023

We're getting a couple false positives on checking the return value from 'save' where we clearly are checking it.

  1. The case where the result is assigned to something, and then checked later:
saved =
  begin
    @thing.save
  rescue SomeOtherError => e
    ...
  end

if saved
  ...
end
  1. The case where the result is checked via an aggregate of some sort:
# any? { ... } may also trigger it but haven't tested, I'm just including it the way I found it in our code,
if @things.map { |thing| !thing.save }.any?
  ...
end
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

1 participant