Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yamlfix overly aggressively removes spaces between list items #230

Closed
andrewimeson opened this issue Apr 3, 2023 · 4 comments
Closed

yamlfix overly aggressively removes spaces between list items #230

andrewimeson opened this issue Apr 3, 2023 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@andrewimeson
Copy link

Description

yamlfix has started removing whitespace between list elements that it previously would leave untouched. I think this is a step too far for a default configuration, because a lot of uses and tools use whitespace to separate items in a list.

Steps to reproduce

Given a YAML file like this

---
hosts: all
tasks:
  - name: Do something
    command: |
      echo something

  - name: Do another thing
    command: |
      echo "another thing"

Current behavior

Yamlfix removes all empty lines

---
hosts: all
tasks:
  - name: Do something
    command: |
      echo something
  - name: Do another thing
    command: |-
      echo "another thing"

Desired behavior

Yamlfix should (at least by default) ignore at least one blank line between items in a list.

Environment

------------------------------------------------------------------
     yamlfix: 1.9.0
     Python: 3.9.16
     Platform: macOS-12.4-arm64-arm-64bit
------------------------------------------------------------------
@andrewimeson andrewimeson added the bug Something isn't working label Apr 3, 2023
@lyz-code
Copy link
Owner

lyz-code commented Apr 4, 2023

Hi @andrewimeson thanks for opening the issue. I'm sorry that you don't like the new behaviour, have you tried playing with the section_whitelines configuration?. You can also try to tweak comments_whitelines. If that still doesn't do for you, you can take a look on the code that manages the whitelines.

Already the configuration of the whitelines is extensive, maybe we can add a new one to disable the whitelines management, but someone would have to do a PR. Can you think of a better solution?

@lyz-code lyz-code added the help wanted Extra attention is needed label Apr 5, 2023
@andrewimeson
Copy link
Author

@lyz-code I tried setting section_whitelines to 1, but it only works for top-level elements

---
hosts: all

tasks:
  - name: Do something
    command: |
      echo something
  - name: Do another thing
    command: |-
      echo "another thing"

@Nikola-Milovic
Copy link

services:
  studio:
    container_name: supabase-studio
  // THIS SPACE IS ALWAYS REMOVED
  kong:
    container_name: supabase-kong
sequence_style = "block_style"
section_whitelines = 1

Same behavior for me as well

@lyz-code
Copy link
Owner

This should be fixed by @Klavionik contribution #244 and is available since 1.10.0 please use the Whitelines Adjustment configuration whitelines.

If it's not we can always reopen the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants