-
Notifications
You must be signed in to change notification settings - Fork 5
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
allow parsing multi-doc yaml files #498
Conversation
Here's an issue I didn't think of. I need to output something sensible in One way I could deal with this would be: getSingleResultLogMessage(result, fileLocation, format) {
if (result.valid === false && format === "text") {
- return formatErrors(fileLocation, result.errors);
+ return formatErrors(`${fileLocation}[${result.documentIndex}]`, result.errors);
}
}
} That is simple and easy, but it means I'll switch from saying
to
in all cases. It would be nice to avoid that given multiple documents in one file is quite an uncommon case. I could do this: let results = [];
for (const filename of filenames) {
const fileResults = await validateFile(filename, config, plugins, cache);
+ const multiDoc = fileResults.length > 1;
results = results.concat(fileResults);
for (const result of results) {
for (const plugin of plugins) {
+ const fileLocation = multiDoc
+ ? `${filename}[${result.documentIndex}]`
+ : filename;
const message = plugin.getSingleResultLogMessage(
result,
- filename,
+ fileLocation,
config.format,
);
if (message != null) { but it feels like a bit of a hack and means the content of I could make some kind of breaking change to Finally, I could indicate this in some way in the |
reckon this is probably good. Needs another read over with fresh eyes though |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #498 +/- ##
==========================================
+ Coverage 96.40% 96.60% +0.19%
==========================================
Files 20 20
Lines 1281 1354 +73
Branches 268 283 +15
==========================================
+ Hits 1235 1308 +73
Misses 45 45
Partials 1 1 ☔ View full report in Codecov by Sentry. |
6342e8c
to
3b64d6b
Compare
Closes #378
Changelog:
parseInputFile()
may now returnDocument[]
documentIndex
property toValidationResult
type