Skip to content

Change empty classes array to one line format

What does this MR do and why?

There has been some unintended churn on the file db/docs/verification_codes.yml recently. Starting with 8837ba86 and then d4e16782 and then be1bffa7

I think this churn is because different versions of libyaml dump multiline empty lists differently and users are getting different results depending on whether they have a version >= 0.2.5 of libyaml.

Changing the empty classes key in this file from:

classes:
-

to

classes: []

Will stop this churn from occurring and will match all of the other empty classes lists in the db/docs directory, e.g here, here, etc ...

This basically reverts the declaration back to how it was before the first of the churn commits listed above.


The multi line format is parsed as an Array with a single nil value, e.g.:

puts YAML.safe_load("---\nclasses:\n-\n").inspect
{"classes"=>[nil]}

This structure is dumped slightly differently by different versions of libyaml and has lead to some unintended churn on this file.

# libyaml < 0.2.5 - note the additional whitespace
puts ({classes: [nil]}.to_yaml.inspect)
"---\n:classes:\n- \n"

# libyaml >= 0.2.5
puts ({classes: [nil]}.to_yaml.inspect)
"---\n:classes:\n-\n"

This change reverts the classes empty array back to a single line representation to match the other files in db/docs which have an empty classes array:

puts YAML.safe_load("---\nclasses: []\n").inspect
{"classes"=>[]}
Edited by Malcolm Locke

Merge request reports

Loading