Skip to content

Commit

Permalink
Merge branch 'feature/squiz-member-function-spacing-add-metrics' of h…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Aug 25, 2019
2 parents 96f878f + a0b5bce commit 55fbe2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ public function process(File $phpcsFile, $stackPtr)
}
}

if ($isLast === true) {
$phpcsFile->recordMetric($stackPtr, 'Function spacing after last', $foundLines);
} else {
$phpcsFile->recordMetric($stackPtr, 'Function spacing after', $foundLines);
}

if ($foundLines !== $requiredSpacing) {
$error = 'Expected %s blank line';
if ($requiredSpacing !== 1) {
Expand Down Expand Up @@ -280,6 +286,10 @@ public function process(File $phpcsFile, $stackPtr)
if ($isFirst === true) {
$requiredSpacing = $this->spacingBeforeFirst;
$errorCode = 'BeforeFirst';

$phpcsFile->recordMetric($stackPtr, 'Function spacing before first', $foundLines);
} else {
$phpcsFile->recordMetric($stackPtr, 'Function spacing before', $foundLines);
}

if ($foundLines !== $requiredSpacing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
}

$foundLines = ($tokens[$first]['line'] - $tokens[$prev]['line'] - 1);

if ($errorCode === 'FirstIncorrect') {
$phpcsFile->recordMetric($stackPtr, 'Member var spacing before first', $foundLines);
} else {
$phpcsFile->recordMetric($stackPtr, 'Member var spacing before', $foundLines);
}

if ($foundLines === $spacing) {
if ($endOfStatement !== false) {
return $endOfStatement;
Expand Down

0 comments on commit 55fbe2d

Please sign in to comment.