Class: Kdep::Doctor::CheckYamlDupKeys

Inherits:
Check
  • Object
show all
Defined in:
lib/kdep/doctor/check_yaml_dup_keys.rb

Overview

A duplicate key is not catchable by review -- in a 50-line file with the two blocks 30 lines apart, they are invisible. It's machine work, and kdep is the one place in the flow that sees every deploy's YAML.

Constant Summary collapse

ID =
"yaml_dup_keys".freeze

Instance Attribute Summary

Attributes inherited from Check

#deploy_dir

Instance Method Summary collapse

Methods inherited from Check

#initialize

Constructor Details

This class inherits a constructor from Kdep::Doctor::Check

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kdep/doctor/check_yaml_dup_keys.rb', line 11

def run
  dups = Kdep::YamlDuplicateKeys.in_dir(deploy_dir)
  return Result.ok(ID) if dups.empty?

  Result.new(
    id: ID,
    severity: :error,
    message: dups.map(&:to_s).join("; "),
    # Deliberately not wired into --fix: merging two blocks means
    # deciding which value survives when the inner keys conflict, and a
    # wrong automatic merge is worse than the bug -- it looks reviewed.
    hint: "Merge the repeated blocks into one by hand."
  )
end