Class: Textus::Doctor::Check::UnownedSchemaFields
- Inherits:
-
Textus::Doctor::Check
- Object
- Textus::Doctor::Check
- Textus::Doctor::Check::UnownedSchemaFields
- Defined in:
- lib/textus/doctor/check/unowned_schema_fields.rb
Instance Method Summary collapse
Methods inherited from Textus::Doctor::Check
Constructor Details
This class inherits a constructor from Textus::Doctor::Check
Instance Method Details
#call ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/textus/doctor/check/unowned_schema_fields.rb', line 5 def call out = [] dir = File.join(store.root, "schemas") return out unless File.directory?(dir) Dir.glob(File.join(dir, "*.yaml")).sort.each do |sp| # rubocop:disable Lint/RedundantDirGlobSort schema = begin Schema.load(sp) rescue StandardError next end unowned = schema.fields.each_with_object([]) do |(name, spec), acc| acc << name if spec.is_a?(Hash) && spec["maintained_by"].nil? end next if unowned.empty? out << { "code" => "schema.unowned_fields", "level" => "info", "subject" => schema.name || File.basename(sp, ".yaml"), "message" => "schema has fields without maintained_by: #{unowned.join(", ")}", "fix" => "add 'maintained_by: <role>' to each field in #{sp} (optional but recommended)", } end out end |