• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AsaiYusuke / jsonpath / 16410926563

21 Jul 2025 07:14AM UTC coverage: 17.851% (-79.5%) from 97.363%
16410926563

Pull #46

github

AsaiYusuke
refactor: move syntax and tests to internal directory

Separate directory structure from public API by relocating syntax
and test files under internal/ directory structure.
Pull Request #46: Move syntax to the internal directory and reorganize tests

181 of 406 new or added lines in 17 files covered. (44.58%)

3 existing lines in 1 file now uncovered.

676 of 3787 relevant lines covered (17.85%)

17.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/syntax/syntax_node_qualifier_filter.go
1
package syntax
2

3
import "reflect"
4

5
type syntaxFilterQualifier struct {
6
        *syntaxBasicNode
7

8
        query syntaxQuery
9
}
10

11
func (f *syntaxFilterQualifier) retrieve(
12
        root, current interface{}, container *bufferContainer) errorRuntime {
×
13

×
14
        switch typedNodes := current.(type) {
×
15
        case map[string]interface{}:
×
16
                return f.retrieveMap(root, typedNodes, container)
×
17

18
        case []interface{}:
×
19
                return f.retrieveList(root, typedNodes, container)
×
20

21
        default:
×
22
                foundType := msgTypeNull
×
23
                if current != nil {
×
24
                        foundType = reflect.TypeOf(current).String()
×
25
                }
×
NEW
26
                return newErrorTypeUnmatched(f.errorRuntime.node, msgTypeObjectOrArray, foundType)
×
27
        }
28
}
29

30
func (f *syntaxFilterQualifier) retrieveMap(
31
        root interface{}, srcMap map[string]interface{}, container *bufferContainer) errorRuntime {
×
32

×
33
        var deepestTextLen int
×
34
        var deepestError errorRuntime
×
35

×
36
        sortKeys := getSortedKeys(srcMap)
×
37

×
38
        valueList := make([]interface{}, len(*sortKeys))
×
39
        for index := range *sortKeys {
×
40
                valueList[index] = srcMap[(*sortKeys)[index]]
×
41
        }
×
42

43
        valueList = f.query.compute(root, valueList)
×
44

×
45
        isEachResult := len(valueList) == len(srcMap)
×
46

×
47
        if !isEachResult {
×
48
                if valueList[0] == emptyEntity {
×
NEW
49
                        return newErrorMemberNotExist(f.errorRuntime.node)
×
50
                }
×
51
        }
52

53
        for index := range *sortKeys {
×
54
                if isEachResult {
×
55
                        if valueList[index] == emptyEntity {
×
56
                                continue
×
57
                        }
58
                }
59
                if err := f.retrieveMapNext(root, srcMap, (*sortKeys)[index], container); err != nil {
×
60
                        if len(container.result) == 0 {
×
61
                                deepestTextLen, deepestError = f.addDeepestError(err, deepestTextLen, deepestError)
×
62
                        }
×
63
                }
64
        }
65

66
        putSortSlice(sortKeys)
×
67

×
68
        if len(container.result) > 0 {
×
69
                return nil
×
70
        }
×
71

72
        if deepestError == nil {
×
NEW
73
                return newErrorMemberNotExist(f.errorRuntime.node)
×
74
        }
×
75

76
        return deepestError
×
77
}
78

79
func (f *syntaxFilterQualifier) retrieveList(
80
        root interface{}, srcList []interface{}, container *bufferContainer) errorRuntime {
×
81

×
82
        var deepestTextLen int
×
83
        var deepestError errorRuntime
×
84

×
85
        valueList := f.query.compute(root, srcList)
×
86

×
87
        isEachResult := len(valueList) == len(srcList)
×
88

×
89
        if !isEachResult {
×
90
                if valueList[0] == emptyEntity {
×
NEW
91
                        return newErrorMemberNotExist(f.errorRuntime.node)
×
92
                }
×
93
        }
94

95
        for index := range srcList {
×
96
                if isEachResult {
×
97
                        if valueList[index] == emptyEntity {
×
98
                                continue
×
99
                        }
100
                }
101
                if err := f.retrieveListNext(root, srcList, index, container); err != nil {
×
102
                        if len(container.result) == 0 {
×
103
                                deepestTextLen, deepestError = f.addDeepestError(err, deepestTextLen, deepestError)
×
104
                        }
×
105
                }
106
        }
107

108
        if len(container.result) > 0 {
×
109
                return nil
×
110
        }
×
111

112
        if deepestError == nil {
×
NEW
113
                return newErrorMemberNotExist(f.errorRuntime.node)
×
114
        }
×
115

116
        return deepestError
×
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc