-
Notifications
You must be signed in to change notification settings - Fork 109
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
Refactor DatasetIssues and Issue classes #2067
Conversation
…ls to add issues. Output formatting still not working.
…d style output. Added filter to dsIssues that returns a new dsISsues object.
… enh/add_subissues
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2067 +/- ##
==========================================
+ Coverage 85.69% 87.23% +1.53%
==========================================
Files 91 139 +48
Lines 3782 6806 +3024
Branches 1220 1604 +384
==========================================
+ Hits 3241 5937 +2696
- Misses 455 779 +324
- Partials 86 90 +4 ☔ View full report in Codecov by Sentry. |
…ls to add issues. Output formatting still not working.
…d style output. Added filter to dsIssues that returns a new dsISsues object.
@rwblair Just a note that I've opened https://github.com/rwblair/bids-validator/pull/10 against this. Issues discovered while attempting to address #2007, but the conflict with this PR was too high to be worth addressing separately. |
…r message so we don't have to hunt for console logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stopped making codeMessage
suggestions. Grabbing food, so submitting now.
context.dataset.issues.add({ | ||
code: 'TSV_ADDITIONAL_COLUMNS_NOT_ALLOWED', | ||
location: context.path, | ||
issueMessage: `Disallowed columns found ${extraCols}`, | ||
rule: schemaPath, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs more than I can do in a suggestion, due to diff, but what about:
for (const col of extraCols) {
context.dataset.issues.add({
code: 'TSV_ADDITIONAL_COLUMNS_NOT_ALLOWED',
subCode: col,
location: context.path,
rule: schemaPath,
})
}
context.dataset.issues.add({ | ||
code: 'TSV_COLUMN_MISSING', | ||
location: context.path, | ||
issueMessage: `Columns cited as index columns not in file: ${missing}.`, | ||
rule: schemaPath, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I think a foreach using subcodes would be good here.
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Towards #2043
This PR flattens the structure of the DatasetIssues and Issue types. It adds a new
subCode
andrule
field for further differentiation of issues. The issues of DatasetIssues are an array instead of as a map on . The nested files maps were removed in favor of creating a separate issue for each infraction file, code and all. With that there was no need to do any look ups of existing issues during validation.addNonSchemaIssue
was removed, its functionality combined with the regularadd
. Both took arrays of files as an argument, but in practice only one file was ever passed to it.The old outputs would have these file objects with path, filenam, and relative path. It wasn't clear to me that those were really necessary. I tried to get away with just using the path to the file as a string for simplicity. But I may be missing something and having a proper File object in there would be better, when we have one.
I renamed
reason
tocodeMessage
since the text was always being drawn from where the code is defined be it schema or nonschema.I renamed
evidence
toissueMessage
since these were always generated at issue creation time during validation.I don't know that either of these is actually clearer.
filter
andgroupBy
have new DatasetIssues objects as part of their returns,while get returns just an array of issues. should
get
return a new DatasetIssues?You can chain calls to
filter
, is that useful? Chaining calls togroupBy
isn't so easy, should it be easy? I had a version of groupBy that accepted an array of Issue keys to nest that would nest the groups of issues in a object for all the unique values of the keys in the order they were given, it was a mess so I removed it.I had played with array of Issue keys being passed into the DatasetIssues constructor and used to set up a bunch of independent maps of values to be indexed on stored in this.groups (
Map<keyof Issue, Map<Issue[keyof Issue]>, Issue[]>
) but then I couldn't imagine it ever being used so I gave up on it.Should DatasetIssues extend array? Push issues to this instead of this.issues. At its heart it is an array with some helper functions.
Currently issues store
codeMessage
s which leads to quite a bit of duplication, they are consistently the longest field in an issue object and make this issues object 10x larger than old one. ThecodeMessages
map in DatasetIssues could be used to keep a single copy of each message so they could be dropped from the Issue object, but then the issue object needs some assemblly when accessed.If only we could store a reference to fields in codeMessages in issues.