Skip to content
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

Add support for error fixing to ArrayDeclaration #378

Merged
merged 2 commits into from
May 20, 2015

Conversation

JDGrimes
Copy link
Contributor

@JDGrimes JDGrimes commented May 3, 2015

This basically synchronizes it with Squiz.Arrays.ArrayDeclaration.
The upstream version is similar, except that we exclude a few errors.
Unfortunately we have to actually comment out the code rather than just
using the upstream sniff and <exclude> in our ruleset, due to a bug
(squizlabs/PHP_CodeSniffer#582). (I’ve also included a fix for another
bug, squizlabs/PHP_CodeSniffer#584.) Because of this, we cannot yet
eliminate duplicated logic from this child sniff.

I think this pretty much maintains the previous behavior, except that I
have added a warning for extra whitespace at the edges of multiline
arrays.

Another note, the whitespace messages are warnings:

array(1, 2); // missing spaces
array(      1, 2        ) // extra spaces

Maybe these should be converted to errors? I'm not sure why they are just warnings (it goes all the way back to Urban Giraffe).

This basically synchronizes it with `Squiz.Arrays.ArrayDeclaration`.
The upstream version is similar, except that we exclude a few errors.
Unfortunately we have to actually comment out the code rather than just
using the upstream sniff and `<exclude>` in our ruleset, due to a bug
(squizlabs/PHP_CodeSniffer#582). (I’ve also included a fix for another
bug, squizlabs/PHP_CodeSniffer#584.) Because of this, we cannot yet
eliminate duplicated logic from this child sniff.

I think this pretty much maintains the previous behavior, except that I
have added a warning for extra whitespace at the edges of multiline
arrays.
@JDGrimes JDGrimes added this to the 0.5.0 milestone May 3, 2015
@JDGrimes
Copy link
Contributor Author

JDGrimes commented May 3, 2015

Note: I don't think this will be compatible withe PHPCS < 2.0. Are we trying to maintain compatibility with 1.5? There is this note in the reademe:

Do ensure, if for example you're using VVV, that you have the latest version of CodeSniffer (earlier versions, e.g. ~1.5.5, may warn about incorrect line indentation on every single line even if your code is actually correct.)

composer.json says that we require ~2.0. Maybe we should make this note more explicit about that.

@westonruter
Copy link
Member

@JDGrimes I don't think we should be trying to maintain compatibility with PHPCS 1.5, no. That readme note is just an old one. There's no need to incur the burden of supporting older versions of PHPCS. Maybe the base sniff class could do a check for the PHPCS version and error-out if it detects that an older version is being used.

@GaryJones
Copy link
Member

I don't think we should be trying to maintain compatibility with PHPCS 1.5, no.

+1.

I know Yoast has currently tied itself to PHPCS 2.2.0 (latest tag is 2.3.2) because one of the tools they use hasn't been updated yet, but there's no need to support PHPCS lower than that.

@JDGrimes
Copy link
Contributor Author

I've converted the warnings to errors in e2c5160. This should be ready to merge.

GaryJones added a commit that referenced this pull request May 20, 2015
…-declaration

Add support for error fixing to ArrayDeclaration
@GaryJones GaryJones merged commit ec5ea0f into develop May 20, 2015
@GaryJones GaryJones deleted the feature/array-declaration branch May 20, 2015 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants