Module: RuboCop::YAMLDuplicationChecker

Defined in:
lib/rubocop/yaml_duplication_checker.rb

Overview

Find duplicated keys from YAML.

Class Method Summary collapse

Class Method Details

.check(yaml_string, filename, &on_duplicated) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/rubocop/yaml_duplication_checker.rb', line 6

def self.check(yaml_string, filename, &on_duplicated)
  # Specify filename to display helpful message when it raises an error.
  tree = YAML.parse(yaml_string, filename: filename)
  return unless tree

  traverse(tree, &on_duplicated)
end