Skip to content

invalid rewrite of if statement to boolean statement #115

@woylie

Description

@woylie

I encountered a small issue with this code:

if feature_image_id || has_branch?(id) || has_organization?(id),
      do: false,
      else: true

Recode wants to change this to:

not (feature_image_id || has_branch?(id) || has_organization?(id))

But this won't work, since feature_image_id is a string (if set), not a boolean, and if the ID is not nil, the statement evaluates to something like not "abc", which results in an ArgumentError, since not expects a boolean.

Workaround is to fix the result by adding an explicit !is_nil.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions