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

protofire / solhint / #1622

02 Jul 2025 08:25PM UTC coverage: 93.402% (-1.8%) from 95.238%
#1622

push

577 of 661 branches covered (87.29%)

1274 of 1364 relevant lines covered (93.4%)

201.79 hits per line

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

85.71
/lib/rules/security/avoid-throw.js
1
const BaseChecker = require('../base-checker')
1✔
2

3
const ruleId = 'avoid-throw'
1✔
4
const meta = {
1✔
5
  type: 'security',
6

7
  docs: {
8
    description: `"throw" is deprecated, avoid to use it.`,
9
    category: 'Security Rules',
10
    notes: [
11
      {
12
        note: 'Solhint allows this rule to automatically fix the code with `--fix` option',
13
      },
14
    ],
15
  },
16

17
  recommended: true,
18
  defaultSetup: 'warn',
19
  fixable: true,
20

21
  schema: null,
22
}
362✔
23

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

29
  ThrowStatement(node) {
30
    this.error(node, '"throw" is deprecated, avoid to use it', (fixer) =>
×
31
      // we don't use just `node.range` because ThrowStatement includes the semicolon and the spaces before it
32
      // we know that node.range[0] is the 't' of throw
33
      // we're also pretty sure that 'throw' has 5 letters
34
      fixer.replaceTextRange([node.range[0], node.range[0] + 5], 'revert();')
35
    )
1✔
36
  }
37
}
38

39
module.exports = AvoidThrowChecker
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