How to lint YAML files, preferably in Ruby
ruby, yaml
Solution
The yamllint command-line tool does what you want:
sudo pip install yamllint
Specifically, it has a rule `key-duplicates` that detects repetitions and keys over-writing one another:
$ yamllint test.yml
test.yml
1:1 warning missing document start "---" (document-start)
4:5 error duplication of key ":name" in mapping (key-duplicates)
(It has many other rules that you can enable/disable or tweak.)
Problem
How do I lint YAML files, without having to upload it to http://yamllint.com ? For example, if I have ``` people: 1: :name: John Smith :name: Jane Smith ``` How do I make it warn me that the last `:name` over-writes the first `:name`? I'm using Ruby 2.1, and Ubuntu 12.04.