-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Files/FileName: only clean up the excluded files when needed
Efficiency tweak. Cleaning the ruleset passed "excluded files" doesn't need to be done time and again every single time this sniff is called. For a normal PHPCS run, where the property is set in a ruleset, doing it once and reusing the cleaned up version in subsequent calls to the sniff will be sufficient. For test runs, this may need to be done more often, but that can be handled by storing the previous value of `$excluded_files_strict_check` property and checking if it has changed before doing the validation. This commit implements this. Additionally it adds some extra safeguards for incorrectly passed "excluded files" paths. Includes removing the `$phpcsFile` parameter from the `is_file_excluded()` method as it is no longer needed by that method. Includes additional unit tests. Includes updating a pre-existing test to pass duplicate excluded files in different ways.
- Loading branch information
Showing
6 changed files
with
113 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Yoast/Tests/Files/FileNameUnitTests/classes/excluded-dot-prefixed.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName excluded_files_strict_check[] ./classes/excluded-dot-prefixed.inc | ||
|
||
<?php | ||
|
||
class Some_Class {} | ||
|
||
// phpcs:set Yoast.Files.FileName excluded_files_strict_check[] |
8 changes: 8 additions & 0 deletions
8
Yoast/Tests/Files/FileNameUnitTests/classes/excluded-illegal.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName excluded_files_strict_check[] classes/../classes/excluded-illegal.inc | ||
|
||
<?php | ||
|
||
class Some_Class {} | ||
|
||
// phpcs:set Yoast.Files.FileName excluded_files_strict_check[] |
8 changes: 8 additions & 0 deletions
8
Yoast/Tests/Files/FileNameUnitTests/classes/excluded-multiple.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!-- Annotation must be on line 2 as this sniff throws issues on line 1 and PHPCS ignores errors on annotation lines. --> | ||
phpcs:set Yoast.Files.FileName excluded_files_strict_check[] classes/excluded-CLASS-file.inc,classes/excluded-multiple.inc | ||
|
||
<?php | ||
|
||
class Some_Class {} | ||
|
||
// phpcs:set Yoast.Files.FileName excluded_files_strict_check[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters