-
Notifications
You must be signed in to change notification settings - Fork 14
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
Means for constructing YAML lint config from input stream. #34
Comments
Hello, Glad to hear it helped. Funnily enough, I was considering such an improvement last week-end, using for the moment a Anyway, why do you think this is not ideal to deal ith I/O's? I'm not opposed to it but for consistency reasons I would then have to transform the current constructors into static factory methods. |
@garretwilson You can review the PR #35. I managed to find a way to use |
Fixed by #35 |
First of all thank you so much for accepting issue #20 and putting out a new release. We're just now integrating the new version into our project, and everything is looking wonderful so far. We've already found a duplicate key that was causing a bug in production we didn't even know about.
This new issue is similar both to issue #20 and also to issue #19. The
YamlLintConfig
class provides as way to parse a configuration from a string:But I couldn't find a way to construct a
YamlLintConfig
instance from anInputStream
. This would be useful if we stored the config YAML file in the class resources, e.g.:A developer can load the resource into a
String
and pass it to theYamlLintConfig
constructor above, but then the developer would have to make sure that they check for the BOM and use the correct charset as discussed in #19. It would be much better if there were a way to construct aYamlLintConfig
from anInputStream
.In fact I don't think it's ideal to be doing I/O in the constructor. A better practice would be to have a static factory method, like this, in
YamlLintConfig
:In fact even for parsing from a
String
, a more modern approach would be to do the parsing in a static factory method; the constructor should usually be reserved for initialization values that have already been obtained somewhere. (I used to put everything in the constructor, too, many years ago.) Something like this:(I got fancy and threw in a
CharSequence
.) But I don't want to quibble—I'm just giving suggestions.The important thing is that we need a way to get a
YamlLintConfig
from an input stream, and have that code correctly determine the charset as in issue #19 .I personally don't need this any time soon — we are already reading from resources and doing the charset detection manually as in issue #19 . I'm just filing this issue to improve the library at some point in the future when you have time.
Cheers!
The text was updated successfully, but these errors were encountered: