-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Deprecate Remaining VIP sniffs #1410
Deprecate Remaining VIP sniffs #1410
Conversation
@tomjn Glad to see the first PR for this. This sniff in my opinion should not be moved, only deprecated. File system writes being forbidden is a VIP specific requirement which does not easily apply to other projects in the WP ecosphere, so this sniff is a candidate for complete removal in 2.0.0. |
Ah, my goal with this PR is mostly to get to grips with the deprecation process for a sniff. This is certainly an issue for VIP, I can't comment on other hosting platforms, but this usually pops up in any situation were the uploads folder doesn't exist on the file system, which is why VIP flags it. But ignoring that, I just want to make sure I'm not making a colossal mess in follow up PRs, so consider this a practice run :) |
The WPCS ruleset is not for specific hosting platforms. Other hosters can - just like Automattic - create their own PHPCS standard based on WPCS and add additional sniffs to it to facilitate their needs.
👍 |
yay travis is happy 🎉 |
@tomjn Do you mean that this PR is ready for review from your point of view ? |
I think I just need to move the content back into the original sniff so
that it's deprecated not migrated, at which point it'll be complete, if all
is good I can apply the same process to the other sniffs. I've set aside
some time later today to go through the rest
…On Thu, 5 Jul 2018 at 01:02, Juliette ***@***.***> wrote:
@tomjn <https://github.com/tomjn> Do you mean that this PR is ready for
review from your point of view ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1410 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADl5_Keb3w-3JUpq_pdI50dFzixhJLcks5uDVeDgaJpZM4VAud5>
.
|
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.
Hi @tomjn, the PR as it is now, is definitely in line with what has been discussed previously 👍
I've left a couple of remarks in line.
On top of that, there are two more things I'd like to discuss/remark:
- IMO it would be good to do the complete VIP deprecation in one go, in the same version of WPCS.
Looking at your own time schedule - will you be ready with all the PRs in the next few days/ by the middle of next week ? If so, then this can go into1.0.0
.
If not or if you are unsure, targeting1.1.0
might make more sense (to be released as soon as all PRs regarding the deprecation of VIP are ready & merged).
In that case, the version number used in@since
and@deprecated
tags should be adjusted. - I'm not sure I see the value in having 7 commits for this - relatively small - change. Is there a pertinent reason not to squash them into one ?
); | ||
|
||
/** | ||
* Don't use. |
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.
I think this needs a better description. The sniff is still active, just deprecated.
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.
Agreed, this is mostly due to copy paste from another deprecated VIP sniff
/** | ||
* Don't use. | ||
* | ||
* @deprecated 1.0.0 |
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.
I would expect a @since 1.0.0 Added to allow for throwing the deprecation notices.
tag here instead.
The method itself is not deprecated, the sniff is.
In that respect, I'm missing a @deprecated
tag in the class docblock.
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.
+1 will change
* | ||
* @return void|int | ||
*/ | ||
public function process_token( $stackPtr ) { |
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.
For consistency with other sniffs which have getGroups()
and process_token()
function declarations, the getGroups()
method normally goes first, the process_token()
method comes after it.
This is in line with the order in which the functions are called - getGroups()
is called from within the register()
method -, as well as the order used in the abstract sniff which this sniff extends.
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.
Done
WordPress-VIP/ruleset.xml
Outdated
</rule> | ||
|
||
<!-- Prevent duplicate messages from deprecated sniff. --> | ||
<rule ref="WordPress.VIP.FileSystemWritesDisallow"> |
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.
This would disable the sniff completely in contrast to deprecating it. I think this block should be removed.
cc96a0d
to
5fb6bb5
Compare
@tomjn Just scanned through the latest update related to the FileSystemWrites sniff and - |
/** | ||
* This sniff is active, but it's deprecated, handle the deprecation notices | ||
* | ||
* @deprecated 1.0.0 Added to allow for throwing the deprecation notices. |
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.
@deprecated
=> @since
@tomjn I can see you are updating the PR with further changes. Could you please ping me when you are ready for the next review ? |
Requested changes were made. Not approving yet as more commits are still being added to this PR.
5fb6bb5
to
79170a3
Compare
@jrfnl So I believe I'm ready for review, my main concern though is I'm unsure why the one travis check is failing :/ Any help appreciated |
The report says:
|
Should be: 👉 Once you fix this one, you'll start getting the same error for most of the others. When referencing sniffs in a ruleset, you need to leave out the |
f5d83d8
to
e62e6cc
Compare
Gah such an obvious mistake, fixed |
@tomjn The build still isn't passing. I suspect this is because of trailing whitespace within the touched XML file. |
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.
@tomjn Ok, I've reviewed the changes and left most feedback inline.
-
As the
AbstractVariableRestrictionsSniff
is now no longer used by any non-deprecated sniffs, I would like to suggest to deprecated the abstract class as well.No warnings need to be thrown for that, it only needs an annotated
@deprecated
tag in the class docblock. -
Looks like the
Sniff::has_html_open_tag()
method from theSniff
class is only used by the now deprecatedAdminBarRemoval
sniff, so it should probably be deprecated as well. -
I'm presuming you meant to amend commit c1736c2 with commit e6b90a2 ? If so, something went wrong there. You may want to have a look at that.
-
As it looks like this PR will be ready in time for the WPCS 1.0.0 release, please incorporate the changes from Add note regarding WordPress-VIP ruleset #1403 + the additional changes suggested in the comments in that PR.
-
I've confirmed that there is trailing whitespace in the VIP XML ruleset. Please tidy it up.
N.B. The AbstractArrayAssignmentRestrictionsSniff
can not be deprecated as it is still in use by the DB.SlowDBQuery
and the WP.PostsPerPage
sniffs which will not be deprecated.
* | ||
* @var bool | ||
*/ | ||
public $error = true; |
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.
I'm presuming this is a copy/paste error as I don't understand why this property would be added.
Please remove it here and everywhere else where it was inadvertently copied into.
@@ -71,15 +94,15 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff { | |||
*/ | |||
protected $target_css_properties = array( | |||
'visibility' => array( | |||
'type' => '!=', | |||
'type' => '!=', |
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.
Please undo this formatting change, here and in the lines below it.
); | ||
} | ||
|
||
if ( false === $this->thrown['FoundPropertyForDeprecatedSniff'] ) { |
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.
The FoundPropertyForDeprecatedSniff
error message is only needed when a sniff has public properties which could be set/changed from within a custom ruleset.
Before throwing the warning, you need to actually check whether the properties have been set from the ruleset, i.e. whether the values for public properties this class uses have been changed.
For this sniff, the only relevant property is the $remove_only
property. The warning should only be thrown when the value for that property is something other than true
.
* @return array <int line number> => <int number of warnings> | ||
*/ | ||
public function getWarningList() { | ||
return array(); | ||
public function getWarningList( $testFile = '' ) { |
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.
This function needs some work.
- Regarding the
switch
: one of the two cases is wrong - both currently refer to theAdminBarRemovalUnitTest.css
file. - Also, all
case
s contain areturn
, so thereturn
statement underneath theswitch
will never be reached. - Lastly, the alignment of the double arrows in the arrays in the case statements is off.
Either way, the function needs to be changed.
); | ||
} | ||
|
||
if ( ! empty( $this->exclude ) |
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.
This sniff also has an error
property which can be changed from within a custom ruleset, so the condition needs to check the value of that property too.
Unit tests need to be added to the unit test case file with the non-default property values to make sure the deprecated property warning is thrown correctly.
&& false === $this->thrown['FoundPropertyForDeprecatedSniff'] | ||
) { | ||
$this->thrown['FoundPropertyForDeprecatedSniff'] = $this->phpcsFile->addWarning( | ||
'The "WordPress.VIP.SessionFunctionsUsageSniff" sniff has been deprecated. Please update your custom ruleset.', |
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.
👉 See previous remark - remove Sniff
@@ -46,6 +69,24 @@ public function register() { | |||
* @return void | |||
*/ | |||
public function process_token( $stackPtr ) { | |||
if ( false === $this->thrown['DeprecatedSniff'] ) { | |||
$this->thrown['DeprecatedSniff'] = $this->phpcsFile->addWarning( | |||
'The "WordPress.VIP.SessionVariableUsageSniff" sniff has been deprecated. Please update your custom ruleset.', |
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.
👉 See previous remark - remove Sniff
*/ | ||
private $thrown = array( | ||
'DeprecatedSniff' => false, | ||
'FoundPropertyForDeprecatedSniff' => false, |
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.
This sniff does not have any public properties which can be changed, so the FoundPropertyForDeprecatedSniff
entry can be removed.
); | ||
} | ||
|
||
if ( ! empty( $this->exclude ) |
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.
This sniff does not have any public properties which can be changed, so this complete code block for the FoundPropertyForDeprecatedSniff
warning can be removed.
@@ -43,6 +66,24 @@ public function register() { | |||
* @return void | |||
*/ | |||
public function process_token( $stackPtr ) { | |||
if ( false === $this->thrown['DeprecatedSniff'] ) { | |||
$this->thrown['DeprecatedSniff'] = $this->phpcsFile->addWarning( | |||
'The "WordPress.VIP.SessionVariableUsageSniff" sniff has been deprecated. Please update your custom ruleset.', |
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.
References the wrong sniff: WordPress.VIP.SessionVariableUsageSniff
should be WordPress.VIP.SuperGlobalInputUsage
.
bea9d9f
to
f1bbf24
Compare
I've addressed a lot of the feedback, integrated the changes suggested in #1403, todo items: |
8ace487
to
e62bf21
Compare
a3b7b84
to
20494c4
Compare
So an updated TODO list:
|
@tomjn Just checking in... will you be able to finish the work on this PR tomorrow so we can include it in the WPCS 1.0.0 release ? 🙏 |
Yesterday was my birthday so I took some time AFK, it's on my todo list though for later today |
@tomjn 👍 and happy birthday and many happy returns! 🎉 |
As far as I can tell, all the parameters for the VIP sniffs are already handled, moving on to unit tests |
For reference I'm using the VIP Slow DB Query tests as a basis since the majority of what I need to do work wise is near identical <?php
// @codingStandardsChangeSetting WordPress.VIP.SlowDBQuery exclude something
$query = 'foo=bar&meta_key=foo';
// @codingStandardsChangeSetting WordPress.VIP.SlowDBQuery exclude false |
14e6919
to
4573545
Compare
4573545
to
50c3471
Compare
The travis builds seem a bit.. off, hmm, only thing to do is the final wording of the VIP deprecation paragraph |
I restarted the one build which errored out and Travis is ok now. |
@tomjn How can we help you to finish the PR ? |
@jrfnl It's just the paragraph for the readme that needs doing, but my mind is blank. I'm also pretty tired out from the last week and have a busy week ahead of me. Chances are I won't be able to do much more on this for a few days, and that all that's actually needed is less than 20 characters of prose. |
@tomjn Hmm... maybe @GaryJones can come up with some good phrasing ? |
I'll come up with something today. |
@jrfnl If the rest of the PR is good, then let's merge it, and I'll re-do my other PR for the readme - that way, we won't be waiting on Tom to merge readme changes into his branch before merging his branch into |
|
@jrfnl I've updated the PR with the version @GaryJones wrote, thanks for the wordsmithing :) |
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.
Let's merge this baby!
To the Files category, and deprecates the old sniff with a warning.
If this PR goes well I hope to do the same to all the other sniffs mentioned in #1409