Skip to content

Commit

Permalink
Squiz/SuperfluousWhiteSpace: bug fix - ignoreBlankLines should only i…
Browse files Browse the repository at this point in the history
…gnore blank lines

Setting `ignoreBlankLines` to true, would now also cause the sniff to ignore single-line comments with superfluous whitespace at the end.

Includes unit test
  • Loading branch information
jrfnl committed Jan 3, 2018
1 parent e22d740 commit 8ac478d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public function process(File $phpcsFile, $stackPtr)

// Ignore blank lines if required.
if ($this->ignoreBlankLines === true
&& trim($tokens[$stackPtr]['content']) === ''
&& $tokens[($stackPtr - 1)]['line'] !== $tokens[$stackPtr]['line']
) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function myFunction2()

}

// Ordinary comment with extra whitespace at the end

// phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false

// Уберём из системных свойств все кроме информации об услугах
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function myFunction2()

}

// Ordinary comment with extra whitespace at the end

// phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false

// Уберём из системных свойств все кроме информации об услугах
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public function getErrorList($testFile='SuperfluousWhitespaceUnitTest.inc')
23 => 1,
28 => 1,
33 => 1,
53 => 1,
49 => 1,
55 => 1,
];
break;
case 'SuperfluousWhitespaceUnitTest.1.js':
Expand Down

0 comments on commit 8ac478d

Please sign in to comment.