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

protofire / solhint / #143829

09 May 2026 04:05PM UTC coverage: 91.906% (-0.3%) from 92.234%
#143829

push

398 of 484 branches covered (82.23%)

1056 of 1149 relevant lines covered (91.91%)

118.14 hits per line

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

60.53
/../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.
×
40
   *
×
41
   * @returns {boolean}
42
   */
×
43
  someParent(node, predicate) {
44
    let parent = node.parent
×
45
    while (parent) {
46
      if (predicate(parent)) {
47
        return true
48
      }
49
      parent = parent.parent
×
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
      }
1✔
62
    }
×
63

×
64
    return null
65
  }
66
}
×
67

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

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

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

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

86
  while (curNode !== undefined && !curNode[property]) {
87
    curNode = curNode.parent
1✔
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