-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Standards should be referenced by name #79
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
1. Install the module via composer by running: | ||
|
||
```bash | ||
$ composer require --dev webimpress/coding-standard | ||
$ composer require --dev webimpress/coding-standard dealerdirect/phpcodesniffer-composer-installer | ||
``` | ||
|
||
2. Add composer scripts into your `composer.json`: | ||
|
@@ -24,15 +24,16 @@ | |
|
||
```xml | ||
<?xml version="1.0"?> | ||
<ruleset name="Webimpress Coding Standard" | ||
<ruleset name="MyCodingStandard" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
<rule ref="./vendor/webimpress/coding-standard/ruleset.xml"/> | ||
|
||
<rule ref="WebimpressCodingStandard"/> | ||
|
||
<!-- Paths to check --> | ||
<file>config</file> | ||
<file>src</file> | ||
<file>test</file> | ||
<file>config/</file> | ||
<file>src/</file> | ||
<file>test/</file> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess these are not really needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really. They show that for example |
||
</ruleset> | ||
``` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="Webimpress Coding Standard" | ||
<ruleset name="WebimpressCodingStandard" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
<description>Webimpress Coding Standard</description> | ||
|
||
<!-- display progress --> | ||
<arg value="p"/> | ||
<arg name="colors"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why these are removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because command line options should be in the user's phpcs.xml, not in the coding standard. |
||
|
||
<!-- PSR-2 base --> | ||
<rule ref="PSR2"> | ||
<!-- Below 2 rules are covered by Generic.PHP.LowerCaseKeyword --> | ||
|
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.
Can you explain what's wrong with that method?
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.
All phpcs ruleset I've seen/made have a name and can be used by its name.
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.
Not sure if this is still relevant, but I came across this PR when looking for something else.
@michalbundyra I've previously seen issues with sniff name based configuration not always working 100% correctly when a ruleset is imported via a file ref vs by name.
I suppose I should do a deep-dive into this at some point, but I agree with the recommendation that standards containing sniffs should be reference-able by name and that the recommendation should be to register them in
installed_paths
and include them by name.Also see my comments here:
dealerdirect/phpcodesniffer-composer-installer
in a new major? slevomat/coding-standard#1413 (comment)dealerdirect/phpcodesniffer-composer-installer
in a new major? slevomat/coding-standard#1413 (comment)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.
Thanks, @jrfnl ! I'll have a look and try to sort it out.