Skip to content

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

@hakanai

Description

@hakanai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions