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

protofire / solhint / #1617

01 Jul 2025 02:56AM UTC coverage: 95.238% (-2.6%) from 97.828%
#1617

push

885 of 973 branches covered (90.96%)

1760 of 1848 relevant lines covered (95.24%)

391.57 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
}
23

24
class AvoidThrowChecker extends BaseChecker {
25
  constructor(reporter) {
26
    super(reporter, ruleId, meta)
27
  }
726✔
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
1✔
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
    )
×
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