Skip to content

Commit

Permalink
Correct formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
idrabenia committed Dec 1, 2017
1 parent bf1790c commit 0c1bd45
Show file tree
Hide file tree
Showing 34 changed files with 121 additions and 121 deletions.
4 changes: 2 additions & 2 deletions lib/comment-directive-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class CommentDirectiveParser {

constructor (tokens) {
constructor(tokens) {
this.lastLine = tokens.tokenSource.line;
this.ruleStore = new RuleStore(this.lastLine);

Expand Down Expand Up @@ -73,7 +73,7 @@ class CommentDirectiveParser {

class RuleStore {

constructor (lastLine) {
constructor(lastLine) {
this.disableRuleByLine = [];
this.disableAllByLine = [];
this.lastLine = lastLine;
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function processStr(inputStr, config={}) {
return reporter;
}

function processFile (file, config) {
function processFile(file, config) {
const report = processStr(fs.readFileSync(file).toString(), config);
report.file = file;

Expand Down
2 changes: 1 addition & 1 deletion lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const CommentDirectiveParser = require('./comment-directive-parser');


class Reporter {
constructor (tokenStream, config) {
constructor(tokenStream, config) {
this.commentDirectiveParser = new CommentDirectiveParser(tokenStream);
this.reports = [];
this.tokenStream = tokenStream;
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/align/array-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ArrayDeclarationChecker extends BaseChecker {
super(reporter);
}

enterTypeName (ctx) {
enterTypeName(ctx) {
this.validateSpaceBeforeBracket(ctx, '[');
this.validateSpaceBeforeBracket(ctx, ']');
}
Expand Down
26 changes: 13 additions & 13 deletions lib/rules/align/brackets-align.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ class BracketsAlign extends BaseChecker {
super(reporter);
}

enterBlock (ctx) {
enterBlock(ctx) {
this.validateBlock(ctx);
}

enterContractDefinition (ctx) {
enterContractDefinition(ctx) {
this.validateBlock(ctx);
}

enterStructDefinition (ctx) {
enterStructDefinition(ctx) {
this.validateBlock(ctx);
}

enterEnumDefinition (ctx) {
enterEnumDefinition(ctx) {
this.validateBlock(ctx);
}

Expand All @@ -46,21 +46,21 @@ class BracketsAlign extends BaseChecker {

class Block {

constructor (ctx) {
constructor(ctx) {
this.ctx = ctx;
}

openBracket () {
openBracket() {
const bracketCtx = this._openBracketCtx();

return (bracketCtx) ? this._makeBracketObj(bracketCtx) : null;
}

isFunctionDefinition () {
isFunctionDefinition() {
return typeOf(this.ctx.parentCtx) === 'functionDefinition';
}

_openBracketCtx () {
_openBracketCtx() {
const children = this.ctx.children;
const openBrackets = children && children.filter(i => i.getText() === '{');

Expand All @@ -75,12 +75,12 @@ class Block {

class OpenBracket {

constructor (ctx) {
constructor(ctx) {
this.ctx = ctx;
this.errorMessage = 'Open bracket must be indented by other constructions by space';
}

isCorrectAligned () {
isCorrectAligned() {
return hasSpaceBefore(this.ctx);
}
}
Expand All @@ -93,18 +93,18 @@ class FunctionOpenBracket extends OpenBracket {

class UsualOpenBracket extends OpenBracket {

constructor (ctx) {
constructor(ctx) {
super(ctx);
this.errorMessage = 'Open bracket must be on same line. It must be indented by other constructions by space';
}

isOnSameLineWithPreviousToken () {
isOnSameLineWithPreviousToken() {
const ctx = this.ctx;

return onSameLine(startOf(ctx), prevToken(ctx));
}

isCorrectAligned () {
isCorrectAligned() {
return super.isCorrectAligned() && this.isOnSameLineWithPreviousToken();
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/align/expression-align.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ExpressionAlignChecker extends BaseChecker {
super(reporter);
}

enterExpression (ctx) {
enterExpression(ctx) {
const expression = Rule.expression;
const term = Term.term;

Expand Down
56 changes: 28 additions & 28 deletions lib/rules/align/indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class IndentChecker {
this.baseIndentMultiplicityValidator = new BaseIndentMultiplicityValidator(indent, reporter);
}

enterBlock (ctx) {
enterBlock(ctx) {
this.blockValidator.validateBlock(ctx);
}

enterContractDefinition (ctx) {
enterContractDefinition(ctx) {
this.blockValidator.validateBlock(ctx);
}

enterStructDefinition (ctx) {
enterStructDefinition(ctx) {
this.blockValidator.validateBlock(ctx);
}

enterEnumDefinition (ctx) {
enterEnumDefinition(ctx) {
this.blockValidator.validateBlock(ctx);
}

Expand All @@ -40,25 +40,25 @@ class IndentChecker {
this.blockValidator.validateBlock(ctx);
}

enterIfStatement (ctx) {
enterIfStatement(ctx) {
const THEN_STATEMENT_POSITION = 4;
const ELSE_STATEMENT_POSITION = 6;
const STATEMENTS_POSITION = [THEN_STATEMENT_POSITION, ELSE_STATEMENT_POSITION];

this.nestedSingleLineValidator.validateMultiple(ctx, STATEMENTS_POSITION);
}

enterWhileStatement (ctx) {
enterWhileStatement(ctx) {
const STATEMENT_POSITION = 4;

this.nestedSingleLineValidator.validate(ctx, STATEMENT_POSITION);
}

enterDoWhileStatement (ctx) {
enterDoWhileStatement(ctx) {
this.nestedSingleLineValidator.validate(ctx, 1);
}

enterForStatement (ctx) {
enterForStatement(ctx) {
this.nestedSingleLineValidator.validate(ctx, ctx.children.length - 1);
}

Expand Down Expand Up @@ -93,7 +93,7 @@ class IndentChecker {
}
}

getLinesWithError () {
getLinesWithError() {
return [].concat(
this.nestedSingleLineValidator.linesWithError,
this.blockValidator.linesWithError
Expand All @@ -105,51 +105,51 @@ class IndentChecker {

class Block {

constructor (ctx) {
constructor(ctx) {
this.ctx = ctx;
this.startBracketIndex = _.memoize(this._startBracketIndex.bind(this));
this.endBracketIndex = _.memoize(this._endBracketIndex.bind(this));
}

_startBracketIndex () {
_startBracketIndex() {
const children = this.ctx.children;
return children && children.map(i => i.getText()).indexOf('{');
}

hasStartBracket () {
hasStartBracket() {
return this.startBracketIndex() !== null && this.startBracketIndex() >= 0;
}

startBracket () {
startBracket() {
return this.ctx.children[this.startBracketIndex()];
}

startBracketLine () {
startBracketLine() {
return this.startBracket().symbol.line;
}

_endBracketIndex () {
_endBracketIndex() {
return this.ctx.children.map(i => i.getText()).indexOf('}');
}

endBracket () {
endBracket() {
const children = this.ctx.children;
return children[children.length - 1];
}

endBracketLine () {
endBracketLine() {
return this.endBracket().symbol.line;
}

endBracketColumn () {
endBracketColumn() {
return this.endBracket().symbol.column;
}

isBracketsOnSameLine () {
isBracketsOnSameLine() {
return this.startBracketLine() === this.endBracketLine();
}

forEachNestedNode (callback) {
forEachNestedNode(callback) {
for (let i = this.startBracketIndex() + 1; i < this.endBracketIndex(); i += 1) {
const curItem = this.ctx.children[i];
const isTerm = curItem.symbol;
Expand All @@ -163,7 +163,7 @@ class Block {

class KnowLineValidator {

constructor (indent, indentUnit, reporter) {
constructor(indent, indentUnit, reporter) {
this.indent = indent;
this.indentUnit = indentUnit;
this.reporter = reporter;
Expand All @@ -182,7 +182,7 @@ class KnowLineValidator {

class BlockValidator extends KnowLineValidator {

constructor (indent, indentUnit, reporter) {
constructor(indent, indentUnit, reporter) {
super(indent, indentUnit, reporter);
}

Expand Down Expand Up @@ -226,17 +226,17 @@ class BlockValidator extends KnowLineValidator {

class NestedSingleLineValidator extends KnowLineValidator {

constructor (indent, indentUnit, reporter) {
constructor(indent, indentUnit, reporter) {
super(indent, indentUnit, reporter);
}

validateMultiple (ctx, indexes) {
validateMultiple(ctx, indexes) {
indexes.forEach(index =>
this.validate(ctx, index)
);
}

validate (ctx, index) {
validate(ctx, index) {
if (ctx.children.length <= index) {
return;
}
Expand All @@ -262,13 +262,13 @@ class NestedSingleLineValidator extends KnowLineValidator {

class BaseIndentMultiplicityValidator {

constructor (indent, reporter) {
constructor(indent, reporter) {
this.reporter = reporter;
this.indent = indent;
this.firstIndent = new Map();
}

validate (linesWithError, ctx) {
validate(linesWithError, ctx) {
const tokens = ctx.parser._input.tokens.filter(i => i.channel === 0 && i.type >= 0);

tokens.forEach(this.applyTokenIndent.bind(this));
Expand Down Expand Up @@ -329,7 +329,7 @@ function correctIndent(curIndent, indentError) {
}


function firstNodeOfLine (ctx) {
function firstNodeOfLine(ctx) {
let rootCtx = ctx;

while (rootCtx.parentCtx && rootCtx.start.line === rootCtx.parentCtx.start.line &&
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/align/no-spaces-before-semicolon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class NoSpacesBeforeSemicolonChecker extends BaseChecker {
super(reporter);
}

exitSourceUnit (ctx) {
exitSourceUnit(ctx) {
TokenList
.from(ctx)
.semicolonTokens()
Expand All @@ -25,7 +25,7 @@ class NoSpacesBeforeSemicolonChecker extends BaseChecker {

class TokenList extends BaseTokenList {

semicolonTokens () {
semicolonTokens() {
return this
.tokens
.filter(i => i.text === ';')
Expand All @@ -36,7 +36,7 @@ class TokenList extends BaseTokenList {

class SemicolonToken extends AlignValidatable(Token) {

constructor (tokens, curToken) {
constructor(tokens, curToken) {
super(tokens, curToken);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/rules/align/space-after-comma.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SpaceAfterCommaChecker extends BaseChecker {
super(reporter);
}

exitSourceUnit (ctx) {
exitSourceUnit(ctx) {
TokenList
.from(ctx)
.commaTokens()
Expand All @@ -26,7 +26,7 @@ class SpaceAfterCommaChecker extends BaseChecker {

class TokenList extends BaseTokenList {

commaTokens () {
commaTokens() {
return this
.tokens
.filter(i => i.text === ',')
Expand All @@ -37,7 +37,7 @@ class TokenList extends BaseTokenList {

class CommaToken extends AlignValidatable(Token) {

constructor (tokens, commaToken) {
constructor(tokens, commaToken) {
super(tokens, commaToken);
}

Expand Down
Loading

0 comments on commit 0c1bd45

Please sign in to comment.