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

protofire / solhint / #143830

09 May 2026 04:05PM UTC coverage: 92.254% (+0.3%) from 91.906%
#143830

push

403 of 482 branches covered (83.61%)

1060 of 1149 relevant lines covered (92.25%)

118.17 hits per line

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

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

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

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

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

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

19
    return node.parent
4✔
20
  }
21

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

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

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

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

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]
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)
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

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

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

18✔
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