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

protofire / solhint / #190088

19 Jun 2026 01:04AM UTC coverage: 91.429% (-0.2%) from 91.602%
#190088

push

397 of 481 branches covered (82.54%)

1056 of 1155 relevant lines covered (91.43%)

117.53 hits per line

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

50.0
/../lib/common/tree-traversing.js
1
class TreeTraversing {
2
  statementNotContains(node, type) {
3
    const statement = this.findParentStatement(node)
×
4

5
    if (!statement) {
×
6
      return false
×
7
    }
8

9
    const itemOfType = this.findDownType(statement, type)
×
10

11
    return itemOfType !== null
×
12
  }
13

14
  findParentStatement(node) {
15
    while (node.parent != null && !node.parent.type.includes('Statement')) {
4✔
16
      node = node.parent
17
    }
4!
18

×
19
    return node.parent
20
  }
21

4✔
22
  findParentType(node, type) {
23
    while (node.parent !== undefined && node.parent.type !== type) {
4✔
24
      node = node.parent
25
    }
26

27
    return node.parent || null
4✔
28
  }
4✔
29

30
  findDownType(node, type) {
31
    if (!node || node.type === type) {
4✔
32
      return node
33
    } else {
34
      return null
35
    }
147✔
36
  }
648✔
37

38
  /**
39
   * Traverses the tree up and checks `predicate` in each node.
147✔
40
   *
41
   * @returns {boolean}
42
   */
43
  someParent(node, predicate) {
4!
44
    let parent = node.parent
×
45
    while (parent) {
46
      if (predicate(parent)) {
47
        return true
4✔
48
      }
1✔
49
      parent = parent.parent
50
    }
51

3!
52
    return false
×
53
  }
×
54

×
55
  *findIdentifier(ctx) {
×
56
    const children = ctx.children
57

58
    for (let i = 0; i < children.length; i += 1) {
59
      if (children[i].constructor.name === 'IdentifierContext') {
60
        yield children[i]
3✔
61
      }
62
    }
63

64
    return null
×
65
  }
×
66
}
67

×
68
TreeTraversing.typeOf = function typeOf(ctx) {
69
  if (!ctx) {
×
70
    return ''
71
  }
72

73
  const className = ctx.constructor.name
74
  const typeName = className.replace('Context', '')
×
75
  return typeName[0].toLowerCase() + typeName.substring(1)
76
}
×
77

×
78
TreeTraversing.hasMethodCalls = function hasMethodCalls(node, methodNames) {
×
79
  const text = node.memberName
80
  return methodNames.includes(text)
81
}
82

×
83
TreeTraversing.findPropertyInParents = function findPropertyInParents(node, property) {
84
  let curNode = node
85

86
  while (curNode !== undefined && !curNode[property]) {
1✔
87
    curNode = curNode.parent
×
88
  }
×
89

90
  return curNode && curNode[property]
91
}
×
92

×
93
module.exports = TreeTraversing
×
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

© 2026 Coveralls, Inc