-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
How to update ruleset when a new version is released? #1821
Comments
The best way is to use Composer and follow the installation guide. With Composer you can easily track what version of WPCS you have installed for your project. Also, it's better not to install phpcs globally, this can just cause you headaches later on. |
@dingo-d OK thanks for that. I'm new to Composer, so let me just confirm what I think you've said. I should be able to use Composer to both check my currently installed version of WPCS and update to the latest version of WPCS. Is that correct?
OK thanks for that. I'm slowly learning that, and will look into installing things by project--thanks. |
I'm not sure how exactly you installed your current phpcs. My guess is that you have it set up globally. If you'd have installed the phpcs using composer, you'd just type |
OK thanks. I located the WPCS folder, and inside, I ran |
It's hard to say without knowing your setup. You'll need to add more information, like file structure, how you installed it in the first place etc. 🙂 |
OK got it. Problem: I don't exactly remember how I installed wpcs or phpcs :-/ Geesh. I was even trying to write everything down during the installation process. But, well, here we are :-) From the wpcs instructions, I used either the Composer method, or the Standalone method. Is there any way I can check? I can say this:
So somehow phpcs is installed inside wpcs. Is that expected during any of the installation procedures? It sounds a bit odd to me. But at the same time, the wpcs 'Composer' installation instructions indicate that it will automatically install PHP_CodeSniffer. So maybe that's how things are done? |
That sounds like the composer installation method. So you should be able to update it using composer 🙂 |
OK thanks for confirming. If an update becomes available, I'll try to use I have a related question. You say that judging from my folder structure, it looks like I used the Composer installation method. And that is the method I believe I used. With that method, is it expected that the |
Let's take away some confusion: The current Composer installation instructions in the readme suggest installing WPCS as a stand-alone project which can then be used system-wide. With an install like that, your directory layout will be like:
For a project-based install, the directory layout will be like:
If your directory looks like the first, throw away the whole wpcs directory and run the original command again to update. If your directory looks like the second, from within your project root, run As a side-note: IMO, we should remove the advise to use |
Related: #481 |
OK thanks for the info, and confirming the directory structures.
Well let's talk about this for a second. My directory does indeed look like the first. But is it absolutely required to throw that away and start over? I ask because this setup is already working as expected and as desired for me. In light of that, I would have no issue leaving it in-place for a bit. If that would be OK, my only questions would be:
If I navigate by command line to the |
With a setup like the first: Yes. And that shouldn't be an issue as - as an end-user - you won't have made any changes to anything in that directory. If you have, that's another issue, but that raises numerous red flags for me.
No, it will not. |
OK. So I understand though--why do you say that? Is it because with my current setup, I will not be able to update WPCS in the future? I'm not trying to argue or say you're wrong--I just want to be sure I'm understanding everything properly :-) |
With the first setup you will not be able to update WPCS at all. Not now and not in the future. That's why. |
OK got it, thanks for confirming. So I now want to throw away and start over. To do so, its clear that I should delete my existing |
I would recommend staying with Composer. Now you have a choice:
For a
|
OK thanks very much for that. Both sets of instructions are reasonably clear, as are the differences between each, and the update instructions. I'm leaning towards the project based install, since it seems slightly less complex (and perhaps more advantageous), but have one additional question before proceeding. In the instructions you mentioned,
Is this to say that at this point, I will also be able to open VSCode, and use the PHP CodeSniffer for Visual Studio Code extension to run my PHP code through PHPCS, while applying the WPCS rules? That is the setup that is currently in-place on my system (screenshot), and my desired functionality. To give you more information on my installation of PHP CodeSniffer for Visual Studio Code, I'm not 100% sure if it has been installed globally or not. I can say that I installed it via VSCode. VSCode indicates, "This extension is enabled globally" (screenshot). But, the files for this extension definitely reside in my specific Windows user directory: |
I don't work with VSCode myself, so I honestly can't advise you on that. I imagine though that a global install might work better for that, but to be sure, you'd need to check the implementation details of the extension you are using. |
OK no worries--I'll work on VSCode integration separately. I carried out the
|
@cagross as per above instructions for project based install:
The |
OK got it. Executing the command
So, it looks like I now have two installations of PHPCS: one a global install and one a by-project install. Would you agree with that assessment? Also, if I open a PHP file in VSCode, it displays an error message:
So I guess we can assume PHPCS for VSCode is pointing to the global install of PHPCS, rather than the project-based install--sound reasonable? That error occurs regardless of what directory houses the PHP file in-question. In light of all that, what would you suggest I do now? As I see it, I have two options:
Would you agree those are my two options right now, or is there perhaps a third I'm overlooking? Of those two options, do you see any benefit of one or the other? Actually, now that I think about it, I think option 2 might be more beneficial to me. I say that because it seems like PHPCS for VSCode is looking at my global PHPCS installation. So option 2 seems like it would have a better chance of getting PHPCS for VSCode to work properly with WPCS (which is my ultimate goal). I personally wouldn't mind a global installation. For the time being, I don't foresee needing different versions of PHPCS or WPCS for different projects. Would you see any issues with attempting option 2? Thanks for your patience so far! :-) |
This commit updates the README guide to be in line with WordPressCS 3.0.0. This commit: * Removes the "Last commit to stable" and "Nr of contributors" badges. * Updates the "Tested on PHP..." badges. * Updates the table of contents to match the new content of the file. * Removes the "Project history" section (has been moved to the wiki). * Makes the pre-requisites for the package more explicit and puts them in a separate section. * Updates the installation instructions and adds update instructions. - Removes the instructions related to stand-alone installs and using `composer create-project`. - The new installation instructions take the changes in Composer 2.2 (permission required for plugins to run) into account. - The new installation instructions include a link to the end user/ruleset maintainer upgrade guide for WPCS 3.0.0 as the initial upgrade may need extra work. * Updates references to the Composer PHPCS plugin to make sure these reference the new name and link to the correct GH repo (as the repo has moved). * Removes the reference to the VIP ruleset which was removed in WPCS 2.0.0 from the "Rulesets" section. * Adds links to the "customizable properties" section for where to find customizable properties for PHPCS native sniffs and sniffs from PHPCSExtra. * Adds the `VariableAnalysis` standard and the `VIP Coding Standards` to the list of optional additional rulesets to use. * Updates the command and output for the example run. * Removes the links to IDE related tutorials in favour of a link to the wiki (to save us having to maintain this list in multiple places). * Ensures the text consistently uses `WordPressCS` instead of `WPCS`. Closes #481 Closes #1821 Closes #1901
I have a couple questions about keeping this ruleset up to date on my system:
FYI my system is a Windows machine. To install the ruleset I used these instructions (in the 3. Installing The WordPress Coding Standards Rules section).
The text was updated successfully, but these errors were encountered: