-
-
Notifications
You must be signed in to change notification settings - Fork 468
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
Support phpcodesniffer-composer-installer for easy integrate code style #855
Conversation
Related: #546 \cc @schlessera |
@Rarst Would you have an opinion on this ? |
Oops, sorry my notifier was broken for some days and I missed bunch of notifications. I am not sure what the installer does in this case. I remember seeing one that copied stuff around and I don't like that approach. In my opinion Composer packages should never be nested and specific case of standards should be handled with configuration rather than location. |
@Rarst this only set |
Ah, good to hear. :) I will try to have a proper look at it and play with later then. |
/cc @Rarst |
As this litterally only adds (There is further documentation outlining the rational behind this change if that helps...) |
I think this makes sense, I can see no downside. I do want to confirm that this will work properly though, since WPCS is actually a bundle of several standards ( #546 could then be closed, as I'd expect that if PHPCS ever does add native support for something like this (which seems unlikely at this point), it would follow the same conventions already being employed by existing plugins. |
I am getting to looking at it properly this week, will report. :) |
Ok, finally got to it. So given this test {
"require" : {
"squizlabs/php_codesniffer" : "^2.0",
"dealerdirect/phpcodesniffer-composer-installer" : "0.3.2",
"wp-coding-standards/wpcs":"dev-patch-1"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/evilebottnawi/WordPress-Coding-Standards"
}
]
} Running <?php
$phpCodeSnifferConfig = array (
'installed_paths' => 'C:\\server\\phpcs-installer-test\\vendor/wp-coding-standards/wpcs',
)
?> I like this approach:
One note on the PR itself — it sets type, but doesn't require installer plugin itself. So it would need either for plugin to be otherwise required or installed globally. If we want to go with this then we should probably require plugin ourselves as well. Notably this will not work on checkout of this repository itself (as opposed to be pulled in as dependency) since installer doesn't seem to currently handle the case (see PHPCSStandards/composer-installer#20 ) so we would have to keep |
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.
- Should
require
orsuggest
the installer plugin. - Should remove
scripts
set up ifrequire
is used. - Could update documentation if
suggest
is used.
@Rarst Should we fix PHPCSStandards/composer-installer#20 before this PR (possibly including the |
That would be cleaner overall, but I don't think it's critical since we currently already handle root case ourselves with |
Possibly superfluous, but this issue provides some more information about the cases the DealerDirect composer plugin handles: PHPCSStandards/composer-installer#24 |
@Rarst PHPCSStandards/composer-installer#20 has been closed and a new release is out. The plugin is now able to handle the root case. |
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.
In terms of the single-line change here, I've got no objection to it being added - it's be up to the external packages to make use of it correctly. On it's own, it's just a line in composer.json
that hopefully won't cause any issues to packages that read type
, but don't understand phpcodesniffer-standard
.
@GaryJones As mentioned in the rational linked in my earlier comment: The |
So the PR should now be updated, as @Rarst requested, to:
My only question is: I was under the impression that there are several different installers for PHPCS standards. This one seems to be well maintained, so I'm fine with using/depending on it. But I would just like to be clear about what affects, if any, this might have on somebody who uses a different installer. I have a feeling if somebody installed WPCS with a different installer, us requiring this installer might cause issues/conflicts—am I correct? |
Given that there is no official way (I think) for installers to claim We could not add the specific plugin to require, more compatible less convenient. |
@Rarst Correct, there is no official way to claim it. My suggestion in that case (when going for the more 'safe' route) would be:
You can still decide (over time), what to do. |
I think being more convenient makes sense here, but I just wanted to be clear that it would potentially have compatibility issues for some people at some point. If it ever were to become a significant issue, we could revisit it. |
From quick search of GH the common practice seems to be declare |
Posted my last comment at the same time as @frenck. On second thought I'd say he is probably correct, and we might want to just suggest the use of the plugin in the README for now, to ease installation. So this PR would be merged as-is, and then the install instructions would be updated to mention this option. |
I'd like to see PS oh dear, we just keep picking on this. :) if @evilebottnawi sick of it I can finish this up [next week]. |
I would also suggest not adding a A require can always be added later. That would also give us time to look at the "conflicting installers" scenario and ways of dealing with it in the plugin, as that is bound to show up anyway... |
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.
To summarize the current status:
This PR needs to be updated as per @frenck's comment:
- Add
suggest
section to thecomposer.json
suggesting thedealerdirect/phpcodesniffer-composer-installer
plugin. - Adjust the
readme
install instructions for Composer to allow the user to make their own choice from the different Composer plugins available which all use this sametype
.
I've rebased & updated the PR. @Rarst @GaryJones Would you mind having another look ? |
Closes #546 |
@@ -13,12 +13,16 @@ | |||
"require" : { | |||
"squizlabs/php_codesniffer": "^2.9.0" | |||
}, | |||
"suggest" : { | |||
"dealerdirect/phpcodesniffer-composer-installer": "*" |
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.
Worth suggesting the alternative as well?
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.
Wouldn't that create the risk of people blindly installing everything that's suggested and then having two plugins doing the same thing (and possibly conflicting with each other) ?
That was the reason for me to just suggest one anyway.
Guys, sorry, i don't have time to this now, feel free to close this PR and create new if something wrong |
@evilebottnawi No worries, we appreciate you taking the initiative for this and getting the discussion going. I've updated your PR (so you'll get whuffies for your work) and hope to get this merged soon. |
|
||
There are two actively maintained Composer plugins which can handle the registration of standards with PHP_CodeSniffer for you: | ||
* [composer-phpcodesniffer-standards-plugin](https://github.com/higidi/composer-phpcodesniffer-standards-plugin) | ||
* [phpcodesniffer-composer-installer](https://github.com/DealerDirect/phpcodesniffer-composer-installer) |
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.
Do these two both work in roughly the same way? How would someone choose between the two?
Worth WPCS picking one as the recommendation, and leaving the other as a link for an alternative, instead of presenting both equally (in this doc)?
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.
Do these two both work in roughly the same way?
AFAIK yes, they do.
How would someone choose between the two?
Probably the same way as when choosing between two different WP plugins to use:
- See if it's still actively maintained, issues are being responded to, has good reviews, how many users it has on packagist.
- Install each, test it, see if you like it and it does what you want.
Worth WPCS picking one as the recommendation, and leaving the other as a link for an alternative, instead of presenting both equally (in this doc)?
We could, but I figured most Composer users would just require
WPCS and see the suggest
and follow that without reading the readme. I'd be happy to adjust it though.
The reason I choose the @Dealerdirect version as the recommendation is that the team of that plugin has been very active trying to help external standards get this issue sorted, created their Composer plugin in response to an issue with another external standard I'm involved with and has been very responsive to queries related to the plugin.
https://github.com/DealerDirect/phpcodesniffer-composer-installer