Replies: 1 comment
-
Hmm I can't think of a reliable way to do that. What I would do though is what other linters/checks do; and be able to 'grandfather' existing errors/warnings; i.e a whitelist of exceptions to checks to ignore. Then you could come up with a yq expression that can, for example, return an array of 'bad' paths of checks that failed, and subtract from that a whitelisted set of exceptions (using 'load' to load the content from a file, and array subtraction to remove). Make sense? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background/Use Case
So I'm doing some checks in a pull request and I need to know the line numbers of the current object/array element. I know which lines in the file have changed and I need to compare that list to the lines of an element to see how they should affect the outcome of a check. For instance if I find an error on a line that was not changed in the current pull request, I'd label that issue a warning instead of an error.
For clarity, I'm checking the contents of YAML that I'm not responsible for writing so I have no control over it. I'm just responsible for writing the checks to validate the contents of the files.
Sample YAML:
Question
I know how to use
key | line
to obtain the first line of an element, but is there a way to obtain the "length"/end of an element?So for this example, I can see the first element of
catpants
spans from lines 2 through 6 counting manually. Is there a programmatic way thatyq
can determine where it ends? I was thinking of getting the index of the current element (which makes sense for arrays, but not sure how this would work for an object). But I'm also not sure that I can jump into a sequence and then query the current index -- is that possible? I couldn't find anything related in the docs. I'm open to alternative solutions as well.Beta Was this translation helpful? Give feedback.
All reactions