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

--write mode creates problematic yaml output with list-of-lists #3226

Closed
MarkusTeufelberger opened this issue Mar 29, 2023 · 2 comments · Fixed by #3671
Closed

--write mode creates problematic yaml output with list-of-lists #3226

MarkusTeufelberger opened this issue Mar 29, 2023 · 2 comments · Fixed by #3671
Assignees
Labels
AAP Ansible Automation Platform bug critical good first issue Bugs ideal for the first time, good for newcomers contributors

Comments

@MarkusTeufelberger
Copy link
Contributor

MarkusTeufelberger commented Mar 29, 2023

Summary

Running ansible-lint --write on https://github.com/ansible-collections/collection_template rewrites some files (sadly expected) but creates additional yaml[hyphens]: Too many spaces after hyphen errors along the way (unexpected).

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
WARNING: PATH altered to include /home/__removed___/.local/pipx/venvs/ansible-lint/bin :: This is usually a sign of broken local setup, which can cause unexpected behaviors.
ansible-lint 6.14.3 using ansible 2.14.1
  • ansible installation method: pipx
  • ansible-lint installation method: pipx
STEPS TO REPRODUCE
git clone https://github.com/ansible-collections/collection_template collection_template
cd collection_template
ansible-lint --write
# some errors/warnings...
ansible-lint --write
# different errors/warnings, including new yaml ones
Desired Behavior

Do not introduce additional issues after --write

Actual Behavior
sections:
- - major_changes
  - Major Changes
- - minor_changes
  - Minor Changes
- - breaking_changes
  - Breaking Changes / Porting Guide
- - deprecated_features
  - Deprecated Features
- - removed_features
  - Removed Features (previously deprecated)
- - security_fixes
  - Security Fixes
- - bugfixes
  - Bugfixes
- - known_issues
  - Known Issues

gets rewritten to:

sections:
  -   - major_changes
      - Major Changes
  -   - minor_changes
      - Minor Changes
  -   - breaking_changes
      - Breaking Changes / Porting Guide
  -   - deprecated_features
      - Deprecated Features
  -   - removed_features
      - Removed Features (previously deprecated)
  -   - security_fixes
      - Security Fixes
  -   - bugfixes
      - Bugfixes
  -   - known_issues
      - Known Issues

this apparently looks even worse than before to yamllint

A correct version could be:

sections:
  -
    - major_changes
    - Major Changes
  -
    - minor_changes
    - Minor Changes
  -
    - breaking_changes
    - Breaking Changes / Porting Guide
  -
    - deprecated_features
    - Deprecated Features
  -
    - removed_features
    - Removed Features (previously deprecated)
  -
    - security_fixes
    - Security Fixes
  -
    - bugfixes
    - Bugfixes
  -
    - known_issues
    - Known Issues
@MarkusTeufelberger MarkusTeufelberger added bug new Triage required labels Mar 29, 2023
MarkusTeufelberger pushed a commit to mgit-at/ansible-collection-roles that referenced this issue Mar 29, 2023
MarkusTeufelberger pushed a commit to mgit-at/ansible-collection-roles that referenced this issue Apr 25, 2023
@priyamsahoo priyamsahoo added good first issue Bugs ideal for the first time, good for newcomers contributors and removed new Triage required labels Apr 26, 2023
@klaus-tux
Copy link
Contributor

klaus-tux commented Apr 28, 2023

I had a look into this and found the following:
Setting self.compact_seq_seq to False in FormattedYAML produces the extra linebreaks, but the nested sequences are indented too far:

sections:
  -
      - major_changes
      - Major Changes
  -
      - minor_changes
      - Minor Changes
...

Unfortunately, I did not find out how to fix the indentation of the inner sequences without screwing up the indentation of all other sequences.

@trishnaguha
Copy link
Member

This is assigned to @Qalthos now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AAP Ansible Automation Platform bug critical good first issue Bugs ideal for the first time, good for newcomers contributors
Projects
Status: Done
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants