From 857a53220dfb7739f89d8868d4463c6fb940fa0c Mon Sep 17 00:00:00 2001 From: Kay Robbins <1189050+VisLab@users.noreply.github.com> Date: Sat, 15 Feb 2025 16:33:30 -0600 Subject: [PATCH] Updated the error codes --- spec_tests/javascriptTests.json | 209 ++++---------------------------- spec_tests/jsonTests.spec.js | 11 +- src/bids/types/file.js | 4 +- src/issues/data.js | 8 +- src/issues/issues.js | 4 +- 5 files changed, 34 insertions(+), 202 deletions(-) diff --git a/spec_tests/javascriptTests.json b/spec_tests/javascriptTests.json index 7ed47a4d..9bf20fe1 100644 --- a/spec_tests/javascriptTests.json +++ b/spec_tests/javascriptTests.json @@ -195,16 +195,16 @@ }, { "error_code": "CHARACTER_INVALID", - "alt_codes": ["TAG_INVALID", "UNITS_INVALID", "VALUE_INVALID"], - "name": "invalid-character-name-value-class-deprecated", - "description": "An invalid character was used in an 8.2.0 or lower style text value class.", + "alt_codes": ["TAG_INVALID", "VALUE_INVALID"], + "name": "invalid-character-name-value-class", + "description": "An invalid character was used in an 8.2.0 or earlier.", "warning": false, "schema": "8.2.0", "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], "tests": { "string_tests": { - "fails": ["Parameter-label/[", "Parameter-label/Taco\u00c3\u201e"], - "passes": ["Parameter-label/Words", "Parameter-label/Taco*"] + "fails": ["Parameter-label/[", "Parameter-label/Taco*", "Label/30$", "Label/30db kg"], + "passes": ["Parameter-label/Words", "Label/30e10", "Label/3e10asdf"] }, "sidecar_tests": { "fails": [ @@ -225,8 +225,26 @@ ] }, "event_tests": { - "fails": [], - "passes": [] + "fails": [ + [ + ["onset", "duration", "HED"], + [4.5, 0, "Label/%max1"] + ], + [ + ["onset", "duration", "HED"], + [4.5, 0, "Label/$30"] + ], + [ + ["onset", "duration", "HED"], + [4.5, 0, "Label/30db kg"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [4.5, 0, "Label/3e10asdf"] + ] + ] }, "combo_tests": { "fails": [], @@ -3378,95 +3396,6 @@ } } }, - { - "error_code": "STYLE_WARNING", - "alt_codes": [], - "name": "style-warning-bad-naming-style", - "description": "An extension or label does not follow HED naming conventions.", - "warning": true, - "schema": "8.3.0", - "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], - "tests": { - "string_tests": { - "fails": ["Red-color/red"], - "passes": ["Blue-color/Blue"] - }, - "sidecar_tests": { - "fails": [ - { - "event_code": { - "HED": { - "face": "Red/red_blech", - "ball": "Blue-color/blue" - } - } - } - ], - "passes": [ - { - "event_code": { - "HED": { - "face": "Red-color/Red", - "ball": "Blue-color/Blue" - } - } - } - ] - }, - "event_tests": { - "fails": [ - [ - ["onset", "duration", "HED"], - [4.5, 0, "Red/red_blech"], - [5.0, 0, "Blue-color/blue"] - ] - ], - "passes": [ - [ - ["onset", "duration", "HED"], - [4.5, 0, "Red-color/Red"], - [5.0, 0, "Blue-color/Blue"] - ] - ] - }, - "combo_tests": { - "fails": [ - { - "sidecar": { - "event_code": { - "HED": { - "face": "Red/red_blech", - "ball": "Blue-color/blue" - } - } - }, - "events": [ - ["onset", "duration", "event_code", "HED"], - [4.5, 0, "face", "Red, Def/MyColor"], - [5.0, 0, "ball", "Green"] - ] - } - ], - "passes": [ - { - "sidecar": { - "event_code": { - "HED": { - "face": "Red-color/Red", - "ball": "Blue-color/Blue" - } - } - }, - "events": [ - ["onset", "duration", "event_code", "HED"], - [4.5, 0, "face", "Blue"], - [5.0, 0, "ball", "Green, Def/MyColor"] - ] - } - ] - } - } - }, { "error_code": "TAG_EMPTY", "alt_codes": [], @@ -7216,94 +7145,6 @@ } } }, - { - "error_code": "TILDES_UNSUPPORTED", - "alt_codes": ["CHARACTER_INVALID"], - "name": "tildes-unsupported", - "description": "The tilde syntax is no longer supported for any version of HED.", - "warning": false, - "schema": "8.3.0", - "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], - "tests": { - "string_tests": { - "fails": ["Red ~ Blue", "Red, Blue ~ Green ~ Yellow"], - "passes": ["Red, Blue"] - }, - "sidecar_tests": { - "fails": [ - { - "event_code": { - "HED": { - "face": "Red ~ Blue", - "ball": "Red, Blue ~ Green ~ Yellow" - } - } - } - ], - "passes": [ - { - "event_code": { - "HED": { - "face": "(Red, Blue), (Green, (Yellow))", - "ball": "(Def/MyColor, Onset),(Def/Acc/3.5)" - } - } - } - ] - }, - "event_tests": { - "fails": [ - [ - ["onset", "duration", "HED"], - [4.5, 0, "Red ~ Blue"], - [5.0, 0, "Red, Blue ~ Green ~ Yellow"] - ] - ], - "passes": [ - [ - ["onset", "duration", "HED"], - [4.5, 0, "(Red, Blue), (Green, (Yellow))"] - ] - ] - }, - "combo_tests": { - "fails": [ - { - "sidecar": { - "event_code": { - "HED": { - "face": "Red ~ Blue", - "ball": "Red, Blue ~ Green ~ Yellow" - } - } - }, - "events": [ - ["onset", "duration", "event_code", "HED"], - [4.5, 0, "face", "Red, Def/MyColor"], - [5.0, 0, "ball", "Blue ~ Green ~ Yellow"] - ] - } - ], - "passes": [ - { - "sidecar": { - "event_code": { - "HED": { - "face": "Acceleration/5 m-per-s^2", - "ball": "Def/Acc/7, Blue" - } - } - }, - "events": [ - ["onset", "duration", "event_code", "HED"], - [4.5, 0, "face", "Blue"], - [5.0, 0, "ball", "Green, Def/MyColor"] - ] - } - ] - } - } - }, { "error_code": "UNITS_INVALID", "alt_codes": [], diff --git a/spec_tests/jsonTests.spec.js b/spec_tests/jsonTests.spec.js index 5d3b7e69..89c03bd6 100644 --- a/spec_tests/jsonTests.spec.js +++ b/spec_tests/jsonTests.spec.js @@ -22,10 +22,9 @@ const runMap = new Map([['TAG_EXPRESSION_REPEATED', ['tags-duplicated-across-mul //const runOnly = new Set(["eventsPass"]) const runOnly = new Set() const skippedErrors = { - VERSION_DEPRECATED: 'not handling in the spec tests.', - ELEMENT_DEPRECATED: 'not handling tag deprecated in the spec tests.', - STYLE_WARNING: 'not handling style warnings at this time', - 'invalid-character-name-value-class-deprecated': 'not handling deprecated in the spec tests.', + TAG_EXTENDED: 'Warning not being checked', + SIDECAR_KEY_MISSING: 'Warning not being checked', + ELEMENT_DEPRECATED: 'Warning not being checked', } const readFileSync = fs.readFileSync const test_file_name = 'javascriptTests.json' @@ -286,9 +285,7 @@ describe('HED validation using JSON tests', () => { return } // Run tests except for the ones explicitly skipped or because they are warnings - if (warning) { - test.skip(`Skipping tests ${error_code} [${name}] skipped because warning not error`, () => {}) - } else if (error_code in skippedErrors) { + if (error_code in skippedErrors) { test.skip(`Skipping tests ${error_code} [${name}] skipped because ${skippedErrors[error_code]}`, () => {}) } else if (name in skippedErrors) { test.skip(`Skipping tests ${error_code} [${name}] skipped because ${skippedErrors[name]}`, () => {}) diff --git a/src/bids/types/file.js b/src/bids/types/file.js index af46fe07..ca5b3519 100644 --- a/src/bids/types/file.js +++ b/src/bids/types/file.js @@ -48,8 +48,8 @@ export class BidsFile { } if (!schemas) { BidsHedIssue.fromHedIssue( - generateIssue('genericError', { - message: 'BIDS file HED validation requires a HED schema, but the schema received was null.', + generateIssue('missingSchemaSpecification', { + message: 'No valid HED schema specification was supplied.', }), { path: this.file.file, relativePath: this.file.file }, ) diff --git a/src/issues/data.js b/src/issues/data.js index 9dce777d..0ef05641 100644 --- a/src/issues/data.js +++ b/src/issues/data.js @@ -400,7 +400,7 @@ export default { missingSchemaSpecification: { hedCode: 'SCHEMA_LOAD_FAILED', level: 'error', - message: stringTemplate`No schema specification was supplied.`, + message: stringTemplate`No valid HED schema specification was supplied.`, }, bundledSchemaLoadFailed: { hedCode: 'SCHEMA_LOAD_FAILED', @@ -468,12 +468,6 @@ export default { level: 'error', message: stringTemplate`The key 'HED' was illegally used within a non-HED sidecar column.`, }, - // Generic errors - genericError: { - hedCode: 'GENERIC_ERROR', - level: 'error', - message: stringTemplate`Unknown HED error "${'internalCode'}" - parameters: "${'parameters'}".`, - }, internalError: { hedCode: 'INTERNAL_ERROR', level: 'error', diff --git a/src/issues/issues.js b/src/issues/issues.js index 36b5c1b0..45f8bf6e 100644 --- a/src/issues/issues.js +++ b/src/issues/issues.js @@ -164,9 +164,9 @@ export class Issue { * @returns {Issue} An object representing the issue. */ export const generateIssue = function (internalCode, parameters) { - const issueCodeData = issueData[internalCode] ?? issueData.genericError + const issueCodeData = issueData[internalCode] ?? issueData.internalError const { hedCode, level } = issueCodeData - if (issueCodeData === issueData.genericError) { + if (issueCodeData === issueData.internalError) { parameters.internalCode = internalCode parameters.parameters = 'Issue parameters: ' + JSON.stringify(parameters) }