Skip to content

Commit

Permalink
Fix "flat is not a function" error
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandomg committed Dec 17, 2019
1 parent 7402d3b commit 457f187
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/rules/best-practises/max-states-count.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const _ = require('lodash')
const BaseChecker = require('./../base-checker')
const { severityDescription } = require('../../doc/utils')

Expand Down Expand Up @@ -59,10 +60,10 @@ class MaxStatesCountChecker extends BaseChecker {
}

ContractDefinition(node) {
const countOfVars = node.subNodes
const countOfVars = _(node.subNodes)
.filter(({ type }) => type === 'StateVariableDeclaration')
.map(subNode => subNode.variables.filter(variable => !variable.isDeclaredConst))
.flat().length
.flatMap(subNode => subNode.variables.filter(variable => !variable.isDeclaredConst))
.value().length

if (countOfVars > this.maxStatesCount) {
this._error(node, countOfVars)
Expand Down

0 comments on commit 457f187

Please sign in to comment.