-
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
[BUG] Default setting (enable
) of empty-values
& octal-values
does nothing
#204
Comments
Hi @myii, thanks for shedding light on this. I agree the default conf for The problem is that it's not easy to change default options: it might break existing configurations and start generating errors in software projects that don't expect it. Including large scale projects (Ansible, OpenStack, Docker...) that can't allow that. |
@adrienverge Thanks for the response. For the time being, I believe it's sufficient to just do one of the things you've mentioned. So either:
The ideal answer is number 1 but it could cause serious issues in projects that are out there. So number 2 is the right option for the time being, so that at least users are informed that these settings are disabled by default. So essentially, all that needs to be changed for now in @@ -18,7 +18,7 @@
document-start:
level: warning
empty-lines: enable
- empty-values: enable
+ empty-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
@@ -26,7 +26,7 @@
line-length: enable
new-line-at-end-of-file: enable
new-lines: enable
- octal-values: enable
+ octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy: What do you think? |
Yeah, 1. cannot be done, it would break many users' configurations. If we |
Apologies, maybe I misunderstood you. Which options should be switched to |
My proposal is to switch from:
to:
(and the same for The goal is:
|
@adrienverge Ah, OK. That sounds like an excellent proposal, which covers the existing uses of |
I agree, but I don't see the fact that these rules are disabled by default as a problem:
Would you like to contribute this change? |
@adrienverge It's not a major issue but there is a problem of expectation: users (like myself) believe that the rules are enabled, since that's what we read in the documentation. I only realised when it was never showing errors which I knew existed in the codebase. Others will be out there who will remain oblivious, thinking it's enabled by default. Perhaps some appropriate message to make them aware of this, that they actually need to add this to their configuration files: empty-values: enable
octal-values: enable
I agree that some rules should be opt-in. These would have been nice if they were working by default but I fully support that
Not sure existing users will check that again after having based their configurations on that. But there's not much more that can be done. Perhaps a specific notice under
Sure, I'll put this through soon. |
@adrienverge I think this is going to need a little more thought: yamllint/tests/rules/test_octal_values.py Line 43 in 579a975
yamllint/tests/rules/test_octal_values.py Line 64 in 579a975
$ python -m unittest -v tests.rules.test_octal_values
test_disabled (tests.rules.test_octal_values.OctalValuesTestCase) ... ok
test_explicit_octal_values (tests.rules.test_octal_values.OctalValuesTestCase) ... FAIL
test_implicit_octal_values (tests.rules.test_octal_values.OctalValuesTestCase) ... FAIL
======================================================================
FAIL: test_explicit_octal_values (tests.rules.test_octal_values.OctalValuesTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/scratch/GitHub/yamllint/tests/rules/test_octal_values.py", line 103, in test_explicit_octal_values
self.check('implicit-octal: 010', conf)
File "/home/scratch/GitHub/yamllint/tests/common.py", line 53, in check
self.assertEqual(real_problems, expected_problems)
AssertionError: Lists differ: [1:20: forbidden implicit octal value "010" (octal-values)] != []
First list contains 1 additional elements.
First extra element 0:
1:20: forbidden implicit octal value "010" (octal-values)
- [1:20: forbidden implicit octal value "010" (octal-values)]
+ []
======================================================================
FAIL: test_implicit_octal_values (tests.rules.test_octal_values.OctalValuesTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/scratch/GitHub/yamllint/tests/rules/test_octal_values.py", line 82, in test_implicit_octal_values
self.check('explicit-octal: 0o10', conf)
File "/home/scratch/GitHub/yamllint/tests/common.py", line 53, in check
self.assertEqual(real_problems, expected_problems)
AssertionError: Lists differ: [1:21: forbidden explicit octal value "0o10" (octal-values)] != []
First list contains 1 additional elements.
First extra element 0:
1:21: forbidden explicit octal value "0o10" (octal-values)
- [1:21: forbidden explicit octal value "0o10" (octal-values)]
+ []
----------------------------------------------------------------------
Ran 3 tests in 0.162s
FAILED (failures=2) |
I get your point, and agree it can be confusing. However this is not specific to
I'm not sure it's really needed, because existing users won't go check there. However, what could be useful is adding a note under all rules that are disabled by default. |
@adrienverge The rest of the rules that are set to In any case, maybe no-one will notice. Then again, I noticed something was wrong and the first place I came back to was the documentation, before rolling up my sleeves to jump into the code! |
There appears to be a contradiction between the meaning of
enable
in the default settings and the actual end result.empty-values
yamllint/yamllint/conf/default.yaml
Line 21 in b62b424
yamllint/yamllint/rules/empty_values.py
Lines 78 to 79 in 0f073f7
octal-values
yamllint/yamllint/conf/default.yaml
Line 29 in b62b424
yamllint/yamllint/rules/octal_values.py
Lines 69 to 70 in 0f073f7
In both cases, the only way to get these working is to specify them in the
.yamllint
file:What is
enable
supposed to do? Otherwise, isn't the default actuallydisable
in both cases, withdefault.yaml
needing updating (with the knock-on affect to the documentation)?The text was updated successfully, but these errors were encountered: