Skip to content

Commit

Permalink
fix protofire#133: do not trigger mark-callable-contracts on enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine committed Aug 7, 2019
1 parent 48c9d80 commit 637277e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/rules/security/mark-callable-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ class MarkCallableContractsChecker {
this.gatherNonContractNames(ctx)
}

enterEnumDefinition(ctx) {
this.gatherNonContractNames(ctx)
}

enterEnumValue(ctx) {
const enumValue = ctx.getText()
this.nonContractNames.push(enumValue)
}

exitStateVariableDeclaration(ctx) {
const hasConstModifier = ctx.children.some(i => i.getText() === 'constant')

Expand Down
16 changes: 16 additions & 0 deletions test/rules/security/mark-callable-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,20 @@ describe('Linter - mark-callable-contracts', () => {

assert.equal(report.warningCount, 0)
})

it('should not return error for enum', () => {
const code = contractWith(`
enum Status { Initial }
function b() public view returns(Status) {
return Status.Initial;
}
`)

const report = linter.processStr(code, {
rules: { 'mark-callable-contracts': 'warn' }
})

assert.equal(report.warningCount, 0)
})
})

0 comments on commit 637277e

Please sign in to comment.