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

protofire / solhint / #19201

09 Sep 2019 05:42PM UTC coverage: 97.828% (-0.03%) from 97.856%
#19201

push

web-flow
Merge pull request #158 from kevsul/fix-reason-string-revert

Fix 'revert' case of reason-string

615 of 691 branches covered (89.0%)

5 of 5 new or added lines in 2 files covered. (100.0%)

1 existing line in 1 file now uncovered.

2927 of 2992 relevant lines covered (97.83%)

117.05 hits per line

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

95.65
/lib/rules/best-practises/no-empty-blocks.js
1
const BaseChecker = require('./../base-checker')
1✔
2
const { typeOf } = require('./../../common/tree-traversing')
1✔
3

4
const ONLY_BRACKETS_LENGTH = 2
1✔
5
const EMPTY_STRUCT_LENGTH = 4
1✔
6
const EMPTY_ENUM_LENGTH = 4
1✔
7

8
const ruleId = 'no-empty-blocks'
1✔
9
const meta = {
1✔
10
  type: 'best-practises',
11

12
  docs: {
13
    description: 'Code contains empty block.',
14
    category: 'Best Practise Rules'
15
  },
16

17
  isDefault: false,
18
  recommended: true,
19
  defaultSetup: 'warn',
20

21
  schema: []
22
}
23

24
class NoEmptyBlocksChecker extends BaseChecker {
25
  constructor(reporter) {
26
    super(reporter, ruleId, meta)
277✔
27
  }
28

29
  exitBlock(ctx) {
30
    this._validateChildrenCount(ctx, ONLY_BRACKETS_LENGTH)
31
  }
8✔
32

33
  exitStructDefinition(ctx) {
34
    this._validateChildrenCount(ctx, EMPTY_STRUCT_LENGTH)
35
  }
6!
UNCOV
36

×
37
  exitEnumDefinition(ctx) {
38
    this._validateChildrenCount(ctx, EMPTY_ENUM_LENGTH)
39
  }
6✔
40

41
  exitAssemblyBlock(ctx) {
42
    this._validateChildrenCount(ctx, ONLY_BRACKETS_LENGTH)
43
  }
2✔
44

45
  exitContractDefinition(ctx) {
46
    this._validateContractPartsCount(ctx)
47
  }
2✔
48

49
  _validateChildrenCount(ctx, count) {
50
    if (ctx.children && ctx.children.length === count) {
51
      this._error(ctx)
2✔
52
    }
53
  }
54

55
  _validateContractPartsCount(ctx) {
12✔
56
    const contractPartCount = ctx.children.filter(i => typeOf(i) === 'contractPart').length
57

58
    if (contractPartCount === 0) {
59
      this._error(ctx)
12✔
60
    }
4✔
61
  }
62

63
  _error(ctx) {
64
    this.warn(ctx, 'Code contains empty block')
65
  }
59✔
66
}
67

12✔
68
module.exports = NoEmptyBlocksChecker
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

© 2025 Coveralls, Inc