Skip to content

Commit

Permalink
added error type property and indentation property
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Fonseca committed Sep 13, 2013
1 parent 06f8dd9 commit 165ec84
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ public function register()

}//end register()

/**
* If true, an error will be thrown; otherwise a warning.
*
* @var bool
*/
public $error = true;

/**
* The number of spaces code should be indented.
*
* @var int
*/
public $indent = 4;

/**
* Processes the tokens that this sniff is interested in.
Expand Down Expand Up @@ -99,7 +112,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$foundIndent = 0;
}

$expectedIndent = ($indentLevel * 4);
$expectedIndent = ($indentLevel * $this->indent);
if ($expectedIndent > 0 && strpos($tokens[$i]['content'], $phpcsFile->eolChar) !== false
) {
if ($nestingLevel !== $indentLevel) {
Expand All @@ -112,7 +125,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$expectedIndent,
$foundIndent,
);
$phpcsFile->addError($error, $i, 'Incorrect', $data);
if ($this->error === true) {
$phpcsFile->addError($error, $i, 'Incorrect', $data);
} else {
$phpcsFile->addWarning($error, $i, 'Incorrect', $data);
}
}

$currentLine = $tokens[$i]['line'];
Expand Down

0 comments on commit 165ec84

Please sign in to comment.