-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Files/FileName: various improvements #2285
Merged
GaryJones
merged 3 commits into
develop
from
feature/filename-dont-assume-file-extension-and-deal-with-other-sep
Jul 4, 2023
Merged
Files/FileName: various improvements #2285
GaryJones
merged 3 commits into
develop
from
feature/filename-dont-assume-file-extension-and-deal-with-other-sep
Jul 4, 2023
Conversation
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
…ash word separators Addresses Gary's question in 2154: > I can see there are some test files with extra `.` in (and not just underscores), but I was wondering if an incorrect file name like `class.my-class.php` might be detected, as the checking for hyphenation only replaces underscores. I have tested this and while the file would already be flagged by the "class name vs file name check", the "is hyphenated" check would not flag the file. Fixed now. Includes extra tests. Note: this fix requires that the numbered test files we were using have to be renamed as the `.#.inc` would cause the sniff to throw errors when there shouldn't be any. Related to issue 2164, but doesn't fix it completely.
…ions Addresses Gary's second question in 2154: > I also see `substr( $file_name, 0, -4 )`, which is assuming that a PHP-rendered file will always have a three letter file extension, but I wonder if someone could break that assumption with `--extensions=php3,myphp` or similar. While I still think we should add a rule about requiring the `.php` extension to the handbook (after a Make post), as that rule currently doesn't exist, the sniff should not assume that all files will have a three character file extension. Fixed now. Includes extra tests. Related to issue 2164, but doesn't fix it completely. (the "check for a `.php` file extension" is not addressed yet as this is not a handbook rule at this time)
In WP 6.1.0, the classes contained in the files listed in `$class_exceptions` were moved to files which comply with the file name requirements. The original files still remain, but no longer contain a class, so we no longer need to make an exception for these in the `check_filename_has_class_prefix()` check. However, with the stricter check for hyphenation-only word separators as introduced in the earlier commit, we do need to continue making an exception for these files for the `check_filename_is_hyphenated()` check. For that reason, the properties remain. Having said that, in this commit: * I remove the check against these properties from the `check_filename_has_class_prefix()` check. * The properties are renamed to `$*hyphenation_exceptions` to better reflect what they are used for. * Two additional non-compliant files from WP Core are added to the list.
dingo-d
approved these changes
Jul 4, 2023
GaryJones
approved these changes
Jul 4, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
GaryJones
deleted the
feature/filename-dont-assume-file-extension-and-deal-with-other-sep
branch
July 4, 2023 11:20
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Files/FileName: improve handling of files using non-underscore, non-dash word separators
Addresses Gary's question in #2154:
I have tested this and while the file would already be flagged by the "class name vs file name check", the "is hyphenated" check would not flag the file.
Fixed now. Includes extra tests.
Note: this fix requires that the numbered test files we were using have to be renamed as the
.#.inc
would cause the sniff to throw errors when there shouldn't be any.Related to issue #2164, but doesn't fix it completely.
Files/FileName: improve handling of files using different file extensions
Addresses Gary's second question in #2154:
While I still think we should add a rule about requiring the
.php
extension to the handbook (after a Make post), as that rule currently doesn't exist, the sniff should not assume that all files will have a three character file extension.Fixed now. Includes extra tests.
Related to issue #2164, but doesn't fix it completely. (the "check for a
.php
file extension" is not addressed yet as this is not a handbook rule at this time)Files/FileName: update for changes in WP Core
In WP 6.1.0, the classes contained in the files listed in
$class_exceptions
were moved to files which comply with the file name requirements.The original files still remain, but no longer contain a class, so we no longer need to make an exception for these in the
check_filename_has_class_prefix()
check.However, with the stricter check for hyphenation-only word separators as introduced in the earlier commit, we do need to continue making an exception for these files for the
check_filename_is_hyphenated()
check.For that reason, the properties remain.
Having said that, in this commit:
check_filename_has_class_prefix()
check.$*hyphenation_exceptions
to better reflect what they are used for.