Skip to content

fmt: Unnecessary expansion of if condition into a block #8894

Description

@charlieegan3

opa fmt unnecessarily expands a one-liner if condition into a block (if { ... }) when the rule head's value expression spans multiple lines, even though the condition itself is a single simple term.

Steps To Reproduce

format this:

  foo := sprintf(
      "%d",
      1,
  ) if allow

and get this

  foo := sprintf(
      "%d",
      1,
  ) if {
      allow
  }

Expected behavior

remain as

  foo := sprintf(
      "%d",
      1,
  ) if allow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions