yamlfixer
yamlfixer copied to clipboard
Files that should be ignored aren't
1️⃣ Description
yamlfixer
passes YAML files through yamllint
by sending their content to yamllint
's standard input.
Due to this behavior, yamllint
doesn't know the input files' names, and so is unable to match them to ignore
directives in .yamllint
, if any is present.
📑 Steps to Reproduce
Steps to reproduce the behavior:
jerome@OPT17844:~/work$ yamllint -v
yamllint 1.26.3
jerome@OPT17844:~/work$ yamlfixer -v
yamlfixer v0.9.13
jerome@OPT17844:~/work$ cat meta/main.yml
---
galaxy_info:
galaxy_tags: []
# List tags for your role here, one per line. A tag is
# a keyword that describes and categorizes the role.
# yamllint repots a comments-indentation problem
jerome@OPT17844:~/work$ yamllint --strict meta/main.yml
meta/main.yml
4:5 warning comment not indented like content (comments-indentation)
# Then we create a .yamllint file
jerome@OPT17844:~/work$ cat .yamllint
---
extends: default
rules:
line-length:
max: 160
comments-indentation:
ignore: |
meta/main.yml
# Now the meta/main.yml file is correctly ignored for rule comments-indentation
jerome@OPT17844:~/work$ yamllint --strict meta/main.yml
jerome@OPT17844:~/work$
# But yamlfixer wants to fix it anyway
jerome@OPT17844:~/work$ yamlfixer --summary meta/main.yml
Files to fix: 1
0 files were already correct before
1 files were modified but problems remain
0 files were entirely fixed
0 files were skipped
0 files were not writable
0 files with unknown status
MODIFIED meta/main.yml (handled 1/1)
jerome@OPT17844:~/work$
2️⃣ Expected behavior
The expected behavior is for yamllint
to not report any comments-indentation
problem on the meta/main.yml
file to yamlfixer
, so that yamlfixer
doesn't try to fix them.
So yamlfixer
should be modified to pass file names to yamllint
for real files, and only pass content on yamllint
's stdin when its own input is stdin.