Comparing version 1.0.13 to 1.0.14
@@ -0,1 +1,2 @@ | ||
const _ = require('lodash'); | ||
@@ -14,7 +15,16 @@ | ||
forEachError(callback) { | ||
this.casesList.forEach(curCase => | ||
curCase.forEachError(this.ctx, callback) | ||
); | ||
errorsTo(callback) { | ||
const validCase = this._validCase(); | ||
validCase && validCase.validate(once(callback)); | ||
} | ||
_validCase() { | ||
for (let curCase of this.casesList) { | ||
if (curCase.syntaxMatch(this.ctx)) { | ||
return curCase; | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
@@ -80,9 +90,9 @@ | ||
forEachError(ctx, callback) { | ||
if (this._syntaxMatch(ctx)) { | ||
this._validate(once(callback)); | ||
errorsTo(ctx, callback) { | ||
if (this.syntaxMatch(ctx)) { | ||
this.validate(once(callback)); | ||
} | ||
} | ||
_syntaxMatch(ctx) { | ||
syntaxMatch(ctx) { | ||
const childs = ctx.children; | ||
@@ -104,3 +114,3 @@ const syntaxMatchers = this.items.filter(i => i.syntaxMatch); | ||
_validate(callback) { | ||
validate(callback) { | ||
return this | ||
@@ -242,3 +252,3 @@ .items | ||
const tokenList = tokens(ctx); | ||
const tokenIndex = tokenList.indexOf(token); | ||
const tokenIndex = _.sortedIndexBy(tokenList, token, token => token.start); | ||
@@ -257,3 +267,3 @@ let prevTokenIndex = tokenIndex - 1; | ||
const tokenList = tokens(ctx); | ||
const tokenIndex = tokenList.indexOf(token); | ||
const tokenIndex = _.sortedIndexBy(tokenList, token, token => token.start); | ||
@@ -260,0 +270,0 @@ let nextTokenIndex = tokenIndex + 1; |
@@ -32,3 +32,3 @@ const Reporter = require('./../reporter'); | ||
) | ||
.forEachError( | ||
.errorsTo( | ||
this.makeReport.bind(this) | ||
@@ -35,0 +35,0 @@ ); |
@@ -112,5 +112,7 @@ const Reporter = require('./../reporter'); | ||
this.ctx = ctx; | ||
this.startBracketIndex = _.memoize(this._startBracketIndex.bind(this)); | ||
this.endBracketIndex = _.memoize(this._endBracketIndex.bind(this)); | ||
} | ||
startBracketIndex () { | ||
_startBracketIndex () { | ||
const children = this.ctx.children; | ||
@@ -132,3 +134,3 @@ return children && children.map(i => i.getText()).indexOf('{'); | ||
endBracketIndex () { | ||
_endBracketIndex () { | ||
return this.ctx.children.map(i => i.getText()).indexOf('}'); | ||
@@ -135,0 +137,0 @@ } |
@@ -22,3 +22,3 @@ const Reporter = require('./../reporter'); | ||
) | ||
.forEachError( | ||
.errorsTo( | ||
this.makeReport.bind(this) | ||
@@ -33,3 +33,3 @@ ); | ||
.term('while').space().term('(').noSpaces().expression().noSpaces().term(')').statement() | ||
.forEachError(ctx, this.makeReport.bind(this)); | ||
.errorsTo(ctx, this.makeReport.bind(this)); | ||
} | ||
@@ -41,3 +41,3 @@ | ||
.term('while').space().term('(').noSpaces().expression().noSpaces().term(')').noSpaces().term(';') | ||
.forEachError(ctx, this.makeReport.bind(this)); | ||
.errorsTo(ctx, this.makeReport.bind(this)); | ||
@@ -52,2 +52,6 @@ this.validateBracketsForDoWhileStatement(ctx); | ||
.cases( | ||
term('for').space().term('(') | ||
.noSpaces().rule('simpleStatement').space().expression().noSpaces().term(';') | ||
.space().expression().noSpaces().term(')').statement(), | ||
term('for').space().term('(').noSpaces().term(';').noSpaces().term(';').noSpaces().term(')') | ||
@@ -78,9 +82,5 @@ .statement(), | ||
.noSpaces().rule('simpleStatement').noSpaces().term(';').space().expression() | ||
.noSpaces().term(')').statement(), | ||
term('for').space().term('(') | ||
.noSpaces().rule('simpleStatement').space().expression().noSpaces().term(';') | ||
.space().expression().noSpaces().term(')').statement() | ||
.noSpaces().term(')').statement() | ||
) | ||
.forEachError(this.makeReport.bind(this)); | ||
.errorsTo(this.makeReport.bind(this)); | ||
} | ||
@@ -87,0 +87,0 @@ |
{ | ||
"name": "solhint", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Solidity Code Linter", | ||
@@ -37,3 +37,2 @@ "main": "solhint.js", | ||
"assert": "1.4.1", | ||
"browserify": "^14.4.0", | ||
"coveralls": "2.13.1", | ||
@@ -40,0 +39,0 @@ "mocha": "3.5.0", |
@@ -1,2 +0,2 @@ | ||
#!/usr/bin/env node | ||
//#!/usr/bin/env node | ||
@@ -12,3 +12,3 @@ const program = require('commander'); | ||
program | ||
.version('1.0.0'); | ||
.version('1.0.14'); | ||
@@ -15,0 +15,0 @@ program |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
4
1322460
54
18435