-
Notifications
You must be signed in to change notification settings - Fork 280
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
yamllint only reports wrong-indentation on the first faulty line #427
Comments
Hello, Yes this is intended. You can see a lot of examples of how yamllint is supposed to behave in A way to see this is the first line is wrongly indented, however it's consistent that the second one is indented as the first one. For your tool, maybe you can parse YAML tokens (especially |
I understand, thanks for your clarification. Having an option in yamllint to report all as errors even if they are consistent with the first line would solve my problem, however I don't think I'm able to send a patch for this unfortunately, and I don't even know if this would be easy to do or not :-( In my tool, which only imports the sys and subprocess modules, I specifically want to avoid having to parse YAML. That's why I let yamllint's parsable output do the job for me, and then all I have to do is mostly to sort warning/errors by line then by column and then insert or delete characters or lines at the right place, based on the line/column reported by yamllint, and offsetting all subsequent errors accordingly. If an additional option in yamllint is not on the horizon, then I believe I'll modify my tool to fake yamllint's output by creating errors for all subsequent lines until their indentation differs from the first erroneous one. If I can make it to work, and if I'm allowed to make it public (not sure yet), would you accept such tool as a contribution to yamllint or do you prefer for it to be kept a separate project ? Have a nice day |
Thanks for the proposal! In my opinion this goes beyond the scope of yamllint and would be better as a separate project. |
@adrienverge ok, thanks anyway. I've been allowed to make it public under the GPLv3+, it's available from https://github.com/opt-nc/yamlfixer in case it might help someone. It's very crude at the moment though, and certainely contains bugs... Thanksfor yamllint ! |
hi, I just discovered your two amazing tools, thanks for that, and i'm stuck at the same point. I'm trying to lint some salt files, with a lot of values as this :
As you said,
which in fact broke yaml. |
Faced with another bug/feature
This yaml will pass |
Similar to @timansky, I have found what I think is a bug (but I could be missing something intended) with the I set my .yamllint to use:
With this setting I would expect in the example below
I have tried searching issues to see if this case has been brought up before, and while there are several similar ones, I don't see this case specifically. Also, I've looked at the indentation test files as pointed to here #427 (comment), but I do not see this test case implemented in the |
Hello @zymurnerd, thanks for these clear details. However:
Let me know whether this is clear :) |
Yes, this is clear. Thank you for the response. I'm still pretty new to YAML and did not realize that would be a valid, yet different, structure. Given that this is a valid and different structure that could easily occur as a typo, would it be appropriate for yamllint to provide a warning, perhaps a suppressible one, when these valid indentations occur and |
I understand the idea! But by design, yamllint always tries to report problems with the form, not the content. Here it's really about what the string contains, it would need to analyze text, and if we did that there would be many other examples of structures to report as "potential typos". Also, it would be annoying for users that use "potentially YAML-looking strings", and would get false positive reports. |
I'm working on a simple tool designed to parse yamllint's output and automatically fix a subset of encountered problems, currently only 11 warning or error conditions are automatically fixed.
It was working just fine until I stumbled upon this problem : yamllint doesn't report all faulty lines with wrong-indentation, only the first one in a block (sort of, I've not done in-depth testing).
Consider the following YAML file
and now consider the output of yamllint with default options and parsable output on this file
I believe yamllint should report the same error on line 9 and line 10, but it only reports it on line 8 (the - user line).
Is this the intended behavior or is it a bug ?
Thanks for your time.
The text was updated successfully, but these errors were encountered: