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

protofire / solhint / #143904

09 May 2026 05:02PM UTC coverage: 97.571% (+0.008%) from 97.563%
#143904

push

585 of 658 branches covered (88.91%)

2691 of 2758 relevant lines covered (97.57%)

120.14 hits per line

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

95.16
/../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) {
473✔
24
      node = node.parent
2,596✔
25
    }
26

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

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

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

52
    return false
18!
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') {
14✔
60
        yield children[i]
61
      }
14✔
62
    }
72✔
63

18✔
64
    return null
65
  }
66
}
67

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

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

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

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

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

1✔
90
  return curNode && curNode[property]
84✔
91
}
92

84✔
93
module.exports = TreeTraversing
535✔
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