« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/checks.js29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/data/checks.js b/src/data/checks.js
index e98f04de..336cd64c 100644
--- a/src/data/checks.js
+++ b/src/data/checks.js
@@ -127,6 +127,22 @@ function bindFindArtistOrAlias(boundFind) {
   };
 }
 
+function getFieldPropertyMessage(yamlDocumentSpec, property) {
+  const {fields} = yamlDocumentSpec;
+
+  const field =
+    Object.entries(fields ?? {})
+      .find(([field, fieldSpec]) => fieldSpec.property === property)
+      ?.[0];
+
+  const fieldPropertyMessage =
+    (field
+      ? ` in field ${colors.green(field)}`
+      : ` in property ${colors.green(property)}`);
+
+  return fieldPropertyMessage;
+}
+
 // Warn about references across data which don't match anything.  This involves
 // using the find() functions on all references, setting it to 'error' mode, and
 // collecting everything in a structured logged (which gets logged if there are
@@ -306,17 +322,10 @@ export function filterReferenceErrors(wikiData, {
               return false;
             }, fn);
 
-            const {fields} = thing.constructor[Thing.yamlDocumentSpec];
-
-            const field =
-              Object.entries(fields ?? {})
-                .find(([field, fieldSpec]) => fieldSpec.property === property)
-                ?.[0];
-
             const fieldPropertyMessage =
-              (field
-                ? ` in field ${colors.green(field)}`
-                : ` in property ${colors.green(property)}`);
+              getFieldPropertyMessage(
+                thing.constructor[Thing.yamlDocumentSpec],
+                property);
 
             const findFnMessage =
               (findFnKey.startsWith('_')