Open lain0 opened 1 month ago
Hi @lain0
Thanks for bringing this up. In this gem we use Ruby's built-in YAML parser/emitter named Psych. If I understand correctly, Psych doesn't seem to support setting the indentation level for Lists/Sequences. There is an :indentation
option, but that doesn't have the effect that you're looking for.
Let me investigate this a bit more and I'll come back to you later.
https://github.com/ruby/psych/issues/190 in that ticket https://jsonformatter.org/yaml-formatter is supposed to be used to check and it's output for my test and your README.md example is the same identation
---
require:
- rubocop-rails
AllCops:
Exclude:
- path/file_exists.rb
- path_with_files/**/*
Rails:
Enabled: true
Layout/LineLength:
Max: 120
Rails/ShortI18n:
Enabled: true
instead of
---
require:
- rubocop-rails
AllCops:
Exclude:
- path/file_exists.rb
- path_with_files/**/*
Rails:
Enabled: true
Layout/LineLength:
Max: 120
Rails/ShortI18n:
Enabled: true
yep but you'r right even psych do it wrong even with :indentation option (
data = Psych.load_file('test.yaml')
out = File.open('out.yaml', 'w') do |file|
file.write(Psych.dump(data))
end
It looks like we cannot/should not fix the indentation problem, in my opinion. What do you think?
For your workflow, could it make sense to have yamllint to autofix the indentation (not just report it) after ruboclean
has run?
There may be even no need to yamllint .rubocop.yml
in the first place, since it has been processed by ruboclean
?
(I'm not here to judge your setup/workflow, please don't get me wrong)
You are right becouse two most problem cases and In both of them i belive we just want to keep identation that we have befor ruboclean. So wnen needed add hook for yamllint after ruboclean is good idea.
After applying
ruboclean .rubocop.yml
with:it makes it like:
and my yamllint returns
error wrong indentation: expected 4 but found 2 (indentation)