Skip to content

Commit

Permalink
Merge pull request #75 from ec-europa/feature/MULTISITE-23205
Browse files Browse the repository at this point in the history
MULTISITE-23205: Exclude yml files from phpcs.
  • Loading branch information
jonhy81 authored Feb 28, 2020
2 parents 4e5d2c3 + df0ce78 commit 8707138
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# QA Automation change log

## Version 4.0.4
* MULTISITE-23205: Exclude yml files from phpcs

## Version 4.0.3
* MULTISITE-22812: Bugfix on docker-compose.yml sniff

Expand Down
9 changes: 8 additions & 1 deletion phpcs/QualityAssurance/Sniffs/Generic/HardcodedPathSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ public function register()
*/
public function process(File $phpcsFile, $stackPtr)
{
$end = (count($phpcsFile->getTokens()) + 1);
// Check whole project for string "sites/".
$fileContent = file_get_contents($phpcsFile->getFilename());
if (strpos($fileContent, 'sites') === false) {
$end = (count($phpcsFile->getTokens()) + 1);
return $end;
}

// If the file extension is equal to '.yml' return.
$fileName = $phpcsFile->getFilename();
$fileExtension = strtolower(substr($fileName, -4));
if ($fileExtension === '.yml') {
return $end;
}

Expand Down

0 comments on commit 8707138

Please sign in to comment.