-
Notifications
You must be signed in to change notification settings - Fork 270
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
comments-indentation: false positive with commented dictionary in list #384
Comments
In order to avoid false positive results about comment identation, Keep in mind that these settings are used only if there is no .yamllint config inside the current repository. Users still have the option to override the default value and reactivate the rule if they want. Related: adrienverge/yamllint#384
In order to avoid false positive results about comment identation, Keep in mind that these settings are used only if there is no .yamllint config inside the current repository. Users still have the option to override the default value and reactivate the rule if they want. Related: adrienverge/yamllint#384
In order to avoid false positive results about comment identation, Keep in mind that these settings are used only if there is no .yamllint config inside the current repository. Users still have the option to override the default value and reactivate the rule if they want. Related: adrienverge/yamllint#384
Thanks for the report @ssbarnea. Any help to find the cause and fix it (with non-regression tests) would be welcome. |
I was aware of this bug for longer period of time but I had the impression that you wanted that behavior so I did not bother to investigate a fix. For the moment I changed the defaults of ansible-lint to disable this specific rule. I am glad that you confirm it as a false-positive, we can now look into addressing it (if we can find time). |
As you point out, this behavior could be wanted in some cases, for example to detect the wrongly-indented comment here: # List of platforms:
platforms:
- name: centos
version: 8
# List of structures:
structures:
- struct1 But since the yamllint error disappears when removing the line |
any workaournd |
Fixed yamllint error excluding following rules. - line-length: Default limit 80 is too small - comments-indentation: This rule is being discussed at adrienverge/yamllint#141 and adrienverge/yamllint#384
Fixed yamllint error excluding following rules. - line-length: Default limit 80 is too small - comments-indentation: This rule is being discussed at adrienverge/yamllint#141 and adrienverge/yamllint#384
Here is an example where yamllint reports an error, even if based on the documented examples it should work fine:
The first commented section is correctly considered well idented but the last one is not. I do mention that this identation is the default one that is applied by IDEs like vscode and assures full reversal via shortcuts (Cmd+/).
As we can see the editor did insert the comment at correct indentation.
I observed that if I removed the line with
version: 8
, yamllint no longer complains about wrong indentation, this should also explain where the bug comes from (assumption that commented line must be part of the previous identation level).This is why you have no problems commenting an entire sequence item at start but not if previous line was a mapping.
The text was updated successfully, but these errors were encountered: