Problem/Motivation
Doesn't compy with it's flavour (core's) PHPCS rules.
Steps to reproduce
See gitlab pipelines.
Proposed resolution
Fix issues in the best way possible and make PHPCS testing fail in gitlab so we keep it fixed.
| Comment | File | Size | Author |
|---|
Issue fork redirect-3324524
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
samitk commentedIssue fixed.
Comment #4
samitk commentedComment #5
rishu_kumar commentedI applied patch #4, it applied cleanly, and all the errors was resolved (see attached images). It can be moved to RTBC.
Thanks
Comment #7
charchil khandelwal commentedComment #8
charchil khandelwal commentedThanks @samit.310@gmail.com, patch #4 applied cleanly, all errors and warnings are fixed.
Moving to RTBC.
Comment #10
charchil khandelwal commentedCreated MR for same.
Please review.
Thank You
Comment #11
Manoj Raj.R commentedLooks like a good catch overall by samit.310@gmail.com.
Comment #12
Manoj Raj.R commentedComment #13
Manoj Raj.R commentedReviewed the MR looks good to me.
After the Merge Request created by Charchil Khandelwal
Can be moved to RTBC.
Good work
Comment #14
Manoj Raj.R commentedComment #15
ptmkenny commentedComment #16
avpadernoRedirect and Response are misspelled.
Since the documentation comment is changed, also the short description for that parameter needs to be changed.
Lines are allowed to be longer than 80 characters, if they are more readable. The changed code is not more readable.
Lines that must be removed are removed, not commented out.
The existing short description is already correct. in the redirect_404 table is correct; in redirect_404 table is not correct.
It should be The mocked time.
The usual short description for modules is Hook implementations for the [module name] module.
The short description does not say anything about the property purpose.
The existing short description is already correct, since it includes the class namespace.
The documentation form for a form builder function is different.
The short description for submission and validation handlers is different.
The existing code is more readable. It just misses a space after the comment delimiter.
A batch callback is not described that way. Drupal coding standards have a section about callbacks.
The documentation for the parameters or the return value is missing.
The short description is merely repeating the function name without underscores.
The short description does not describe what the function does. Redirect status code. does not even make sense.
The parameter nor the return value are not described.
The function name is correct because, as the short description says, that hook is implemented on behalf of locale.module.
If I were to implement
hook_entity_alter()in my module on behalf of the Node module, the function name would benode_entity_alter().The short description is missing an article.
Manager is misspelled, since it is not the first word in a sentence.
There is no need to say it is a service.
Words are written capitalized in few cases, none of them include Redirect nor Checker.
The short description is sufficient.
The existing short description is already correct, since it includes the class namespace.
The existing short description is already correct, since it does not repeat the class name.
The short description for a class must not repeat the class name.
It is not necessary to say it is a service, since a manager class is used for a service.
It is not necessary to say it is a service.
The class name must include its namespace.
Redirect and Repository are misspelled.
The last short description is wrong. It is the exact same short description given for the other parameter.
Find a better way how to verify the path is valid. is probably better.
That code is not more readable.
The short description is missing an article. Furthermore, the short description does not need to say the property type.
The short description contains a typo.
The short description should be more specific. That same description has been used for two classes already.
The verb does not use the third-person singular.
The class namespace is missing.
The parameter descriptions are missing.
The short description must not repeat the class name.
The short description is missing an article.
The class namespace is missing from the constructor short description.
Since the documentation comment is changed, also that short description must be corrected.
That is a too vague short description, which could describe any repository.
The short description is too generic.
The code indentation is wrong.
Since the Drupal coding standards say to use the short array syntax, that should be used even for commented out code.
Instead of reformatting the comment, that comment should be removed, as it does not say anything that is already clear from the code.
Formatting rules do not change whether the code is commented out. Those changes are wrong.
If it is a redirect entity, its type cannot be a string.
The short description is missing an article.
I would rather use a comma instead of an hyphen.
Url is misspelled.
The short description is missing an article.
The short descriptions are each missing an article.
That does not describe the return value.
The existing code is more readable.
URl is misspelled.
Comment #17
ankitv18 commentedComment #18
avpadernoThe status is still Needs work, since no new patch nor new MR has been provided. When that is done, the status becomes Needs review, not Active.
Comment #20
jweowu commentedIt was noted in #15 but there was already a mostly-duplicate issue #2957751: Maintaining drupal coding standards -- and as I've just re-rolled the patch for that, I'm marking this one postponed to prevent any more duplication of effort.
I'm not closing this as a duplicate issue because I've noted some phpcs issues which I did not fix in that other patch; namely:
*
\Drupal calls should be avoided in classes, use dependency injection instead*
unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.I think once the coding standards issue has been resolved, this one can be re-opened to address any remaining phpcs concerns.
Comment #21
alexpottComment #24
alexpottI've rolled a new branch on top of #3540774: MakingCSpell pass and fail in future as that would be good to land first and then fixed all the reported PHPCS issues. Going to leave at needs work so we can merge the MR after the other issue lands.
Comment #26
avpadernoComment #27
alexpottMerged in 8.x-1.x and now we're good to go! Green PHPCS run and will error on fail.
Comment #30
alexpottComment #31
alexpottWe need to land #3541107: Drop Drupal 9 and PHP 7 support first.
Comment #32
berdirthat is in.
I considered if we should resolve some phpstan issues on changed lines, but they all seem to be non-trivial, like the removed exception that indicates dead/broken code, not sure if that was ever valid and what changed, so lets not.
The part that's not clear for me yet is the hook changes, I know some hooks don't exist anymore, but not sure how that's related to phpcs and didn't see any explanation or discussion on that here.
Comment #33
alexpottThe redirect.api.php stuff is changed because we've got PHPCS issues in the file
And it seems silly to fix things that are just not relevant anymore.
Re the PHPStan issues - I think we should address all of that in the follow-up - #3451531: PHPStan issue report in gitlab
Comment #34
alexpottMore info on the .api.php changes... there are 3 hooks where this MR is remeving docs:
hook_redirect_load: the signature is wrong and this better documented by hook_ENTITY_TYPE_load() in entity.api.phphook_redirect_load_by_source_alter: does not exist anymorehook_redirect_prepare: does not exist anymore and is replaced by hook_ENTITY_TYPE_prepare_form (which is documented in entity.api.php)Comment #36
berdirMerged, thanks. if this gets too tedious to maintain with minor core phpcs changes I might change the flag in the future.