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

protofire / solhint / #143846

09 May 2026 04:07PM UTC coverage: 97.831% (+5.8%) from 92.08%
#143846

push

589 of 666 branches covered (88.44%)

2796 of 2858 relevant lines covered (97.83%)

119.24 hits per line

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

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

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

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

11
    return itemOfType !== null
2✔
12
  }
13

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

19
    return node.parent
2✔
20
  }
21

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

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

30
  findDownType(node, type) {
31
    if (!node || node.type === type) {
52✔
32
      return node
1✔
33
    } else {
51✔
34
      return null
49✔
35
    }
36
  }
32✔
37

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

52
    return false
53
  }
15✔
54

55
  *findIdentifier(ctx) {
15✔
56
    const children = ctx.children
79✔
57

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

64
    return null
65
  }
1✔
66
}
557✔
67

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

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

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

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

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

90
  return curNode && curNode[property]
91
}
1✔
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