Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Use intersection to find existing events.json files #1574

Merged
merged 2 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bids-validator/tests/events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,8 @@ describe('Events', function () {
jsonFiles,
'',
).then((issues) => {
assert.strictEqual(issues.length, 2)
assert.strictEqual(issues.length, 1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this test, I couldn't see why this used to be 2. Seems like it could have been a meaningless duplicate, so this fix seems sensible, but would want confirmation.

assert.strictEqual(issues[0].code, 105)
assert.strictEqual(issues[1].code, 105)
})
})
})
Expand Down
7 changes: 5 additions & 2 deletions bids-validator/validators/events/hed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hedValidator from 'hed-validator'
import union from 'lodash/union'
import intersection from 'lodash/intersection'
import utils from '../../utils'
import parseTsv from '../tsv/tsvParser'

Expand Down Expand Up @@ -72,7 +72,10 @@ function constructSidecarData(eventData, jsonContents, jsonFiles) {
eventFileData.potentialSidecars,
)
}
const actualEventSidecars = union(actualSidecarNames, potentialEventSidecars)
const actualEventSidecars = intersection(
actualSidecarNames,
potentialEventSidecars,
)
return actualEventSidecars.map((sidecarName) => {
return new hedValidator.validator.BidsSidecar(
sidecarName,
Expand Down