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

protofire / solhint / #1749

28 Jan 2020 06:12PM UTC coverage: 96.241% (-1.3%) from 97.582%
#1749

push

fvictorio
Merge branch '3.0' of github.com:protofire/solhint into 3.0

362 of 437 branches covered (82.84%)

1946 of 2022 relevant lines covered (96.24%)

43.04 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) {
127✔
24
      node = node.parent
544✔
25
    }
26

27
    return node.parent || null
127✔
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
  findTypeInChildren(ctx, type) {
39
    if (ctx.children) {
×
40
      const items = ctx.children.filter(i => i.constructor.name === type)
×
41

42
      return (items.length > 0 && items[0]) || null
×
43
    } else {
44
      return null
×
45
    }
46
  }
47

48
  *findIdentifier(ctx) {
49
    const children = ctx.children
×
50

51
    for (let i = 0; i < children.length; i += 1) {
×
52
      if (children[i].constructor.name === 'IdentifierContext') {
×
53
        yield children[i]
×
54
      }
55
    }
56

57
    return null
×
58
  }
59
}
60

61
TreeTraversing.typeOf = function typeOf(ctx) {
1✔
62
  if (!ctx) {
×
63
    return ''
×
64
  }
65

66
  const className = ctx.constructor.name
×
67
  const typeName = className.replace('Context', '')
×
68
  return typeName[0].toLowerCase() + typeName.substring(1)
×
69
}
70

71
TreeTraversing.hasMethodCalls = function hasMethodCalls(node, methodNames) {
1✔
72
  const text = node.memberName
23✔
73

74
  return methodNames.includes(text)
23✔
75
}
76

77
TreeTraversing.findPropertyInParents = function findPropertyInParents(node, property) {
1✔
78
  let curNode = node
18✔
79

80
  while (curNode !== undefined && !curNode[property]) {
18✔
81
    curNode = curNode.parent
41✔
82
  }
83

84
  return curNode && curNode[property]
18✔
85
}
86

87
module.exports = TreeTraversing
1✔
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