openrewrite / rewrite

Automated mass refactoring of source code.
https://docs.openrewrite.org
Apache License 2.0
2.26k stars 338 forks source link

Merge recipe with sequences within map bad indent #1292

Closed ruben-garciapariente closed 2 years ago

ruben-garciapariente commented 2 years ago

Hello,

I am using the org.openrewrite.yaml.MergeYaml recipe and apparently it is not indenting the sequences correctly.

My source yaml is

noncore:
  key1: value01

My recipe is

  - org.openrewrite.yaml.MergeYaml:
      key: "$"
      yaml: >
        core:
          - map2:
              value:
                - 1
                - 2
      acceptTheirs: true
      fileMatcher: "**/application*.yml"

I expect something like

noncore:
  key1: value01
core:
  - map2:
      value:
        - 1
        - 2

But in the execution we see that the sequence that is inside a map has wrong identation

noncore:
  key1: value01
core:
  - map2:
      value:
  - 1
  - 2

We have a complete example in https://github.com/ruben-garciapariente/test-openwrite/tree/merge-sequence-bug-2

We are testing with 7.17.0-SNAPSHOT, if we test with version 7.16.0 we have the issue fixed in https://github.com/openrewrite/rewrite/issues/1275

Thank you very much

sambsnyd commented 2 years ago

Thanks for the thorough bug report @ruben-garciapariente. It's especially helpful that you tried both 7.16.0 and 7.17.0. We'll look into this soon