Class: Yamlint::Rules::KeyDuplicates
- Defined in:
- lib/yamlint/rules/key_duplicates.rb
Defined Under Namespace
Classes: DuplicateKeyHandler
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
defaults, desc, #fixable?, inherited, #initialize, rule_id
Constructor Details
This class inherits a constructor from Yamlint::Rules::Base
Instance Method Details
#check(context) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/yamlint/rules/key_duplicates.rb', line 12 def check(context) handler = DuplicateKeyHandler.new parser = Psych::Parser.new(handler) handler.parser = parser begin parser.parse(context.content) rescue Psych::SyntaxError return [] end handler.problems.map do |prob| problem( line: prob[:line], column: prob[:column], message: "duplicate key \"#{prob[:key]}\"", fixable: false ) end end |