Skip to content

Format long one-line boolean checks to if statements #222

Description

@sethaxen

It would be useful to have something like short_to_long_function_def for boolean checks. Currently statements like this

function foo()
    my_really_really_really_long_boolean_check() && return my_really_really_really_long_function_name()
end

get formatted to this, so the result is separated from the conditional:

function foo()
    my_really_really_really_long_boolean_check() &&
    return my_really_really_really_long_function_name()
end

But I would like an option for it to be formatted to this:

function foo()
    if my_really_really_really_long_boolean_check()
        return my_really_really_really_long_function_name()
    end
end

Likewise this:

function foo()
    my_really_really_really_long_boolean_check() || return my_really_really_really_long_function_name()
    return 1
end

should be formatted to this:

function foo()
    if !my_really_really_really_long_boolean_check()
        return my_really_really_really_long_function_name()
    end
    return 1
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    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