Skip to content

Avoid converting if/else into long ternary #243

Closed
@gschlager

Description

@gschlager

The formatter should avoid converting if/else into ternary if the the resulting line would be too long. I think stree should disregard the configured print-width and use regular if/else when the line length of the ternary exceeds ~60 chars.

Original (easy to read):

if fits_into_octal?(value, length)
  to_octal(value, length)
else
  to_base256(value, length)
end

Formatted with stree (harder to read):

fits_into_octal?(value, length) ? to_octal(value, length) : to_base256(value, length)

(Tested with print-width of 100)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions