mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-06 21:55:37 +00:00
Compare commits
3 Commits
06f306a477
...
b039bf5d54
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b039bf5d54 | ||
|
|
6a965bc39a | ||
|
|
97355c902b |
@ -911,7 +911,7 @@ func stringsEqual(a, b []string) bool {
|
||||
return false
|
||||
}
|
||||
for i := range a {
|
||||
if a[i] != b[i] {
|
||||
if a[i] != b[i] { //nolint:gosec // G602 false positive: b length equality is checked above
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,3 +54,25 @@ func TestAllAtOnceEvaluateNodes(t *testing.T) {
|
||||
test.AssertResultComplex(t, tt.expected, resultsToString(t, list))
|
||||
}
|
||||
}
|
||||
|
||||
func TestTomlDecoderCanBeReinitializedAcrossDocuments(t *testing.T) {
|
||||
decoder := NewTomlDecoder()
|
||||
|
||||
firstDocuments, err := ReadDocuments(strings.NewReader("id = \"Foobar\"\n"), decoder)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read first TOML document: %v", err)
|
||||
}
|
||||
if firstDocuments.Len() != 1 {
|
||||
t.Fatalf("expected first document count to be 1, got %d", firstDocuments.Len())
|
||||
}
|
||||
test.AssertResult(t, "Foobar", firstDocuments.Front().Value.(*CandidateNode).Content[1].Value)
|
||||
|
||||
secondDocuments, err := ReadDocuments(strings.NewReader("id = \"Barbar\"\n"), decoder)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read second TOML document: %v", err)
|
||||
}
|
||||
if secondDocuments.Len() != 1 {
|
||||
t.Fatalf("expected second document count to be 1, got %d", secondDocuments.Len())
|
||||
}
|
||||
test.AssertResult(t, "Barbar", secondDocuments.Front().Value.(*CandidateNode).Content[1].Value)
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ func (n *CandidateNode) AddChild(rawChild *CandidateNode) {
|
||||
|
||||
func (n *CandidateNode) AddChildren(children []*CandidateNode) {
|
||||
if n.Kind == MappingNode {
|
||||
for i := 0; i < len(children); i += 2 {
|
||||
for i := 0; i < len(children)-1; i += 2 {
|
||||
key := children[i]
|
||||
value := children[i+1]
|
||||
n.AddKeyValueChild(key, value)
|
||||
|
||||
@ -44,6 +44,7 @@ func (dec *tomlDecoder) Init(reader io.Reader) error {
|
||||
}
|
||||
dec.pendingComments = make([]string, 0)
|
||||
dec.firstContentSeen = false
|
||||
dec.finished = false
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ func GetLogger() *logging.Logger {
|
||||
}
|
||||
|
||||
func getContentValueByKey(content []*CandidateNode, key string) *CandidateNode {
|
||||
for index := 0; index < len(content); index = index + 2 {
|
||||
for index := 0; index < len(content)-1; index = index + 2 {
|
||||
keyNode := content[index]
|
||||
valueNode := content[index+1]
|
||||
if keyNode.Value == key {
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
# TODO: Check if the found golangci-lint version matches the expected version (e.g., v1.62.0), especially if falling back to PATH version.
|
||||
|
||||
GOPATH_LINT="$(go env GOPATH)/bin/golangci-lint"
|
||||
BIN_LINT="./bin/golangci-lint"
|
||||
LINT_CMD=""
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
go mod download golang.org/x/tools@latest
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.5
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.11.3
|
||||
curl -sSfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s v2.22.11
|
||||
Loading…
Reference in New Issue
Block a user