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

Static tests: forbid 'or' instead of '||' #21062. #21275

Conversation

novikor
Copy link
Contributor

@novikor novikor commented Feb 15, 2019

Description (*)

Added Squiz.Operators.ValidLogicalOperators PHP-CS rule

Fixed Issues (if relevant)

  1. Static tests: forbid 'or' instead of '||' #21062: Static tests: forbid 'or' instead of '||'

Manual testing scenarios (*)

Just make sure PHP-CS asks you to avoid the literal logical operators
image

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @novikor. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@magento-engcom-team magento-engcom-team added Release Line: 2.3 Partner: ISM eCompany Pull Request is created by partner ISM eCompany partners-contribution Pull Request is created by Magento Partner labels Feb 15, 2019
@novikor novikor requested a review from orlangur February 15, 2019 15:36
@sivaschenko
Copy link
Member

Hi @novikor, thanks for the pull request! Considering that logical_operators is a risky fixer (more details PHP-CS-Fixer/PHP-CS-Fixer#1212), I wouldn't add it to the default list of fixers. I think it's better to allow the individuals who are confident about it to add the fixer to their local configuration file.

image

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having risky rule is totally fine while we have static test which uses php-cs-fixer in dry run mode.

Please add such test and also corresponding phpcs sniff wouldn't hurt.

Please preserve alphabetical order of fixers.

@novikor
Copy link
Contributor Author

novikor commented Feb 24, 2019

Having risky rule is totally fine while we have static test which uses php-cs-fixer in dry run mode.

Please add such test and also corresponding phpcs sniff wouldn't hurt.

Please preserve alphabetical order of fixers.

Hi.
I have already added this rule into static tests and phpcs: magento/magento-coding-standard#40
As I understand, nothing can be done anymore in this PR?

@novikor
Copy link
Contributor Author

novikor commented Feb 24, 2019

@orlangur , may I just update phpunit.xml.dist from https://github.com/magento/magento-coding-standard ?

@orlangur
Copy link
Contributor

@novikor php-cs-fixer integration could be done in this PR :)

What would you like to add from phpunit.xml.dist?

@novikor
Copy link
Contributor Author

novikor commented Feb 25, 2019

@orlangur , I am a little bit confused about php-cs-fixer. As it was mentioned before, it is risky rule so it is not recommended to add into default rules list.

I would like to add changes from https://github.com/magento/magento-coding-standard/pull/40/files#diff-eb0df15a533f0e9054dc4d489ee5e67a

@orlangur
Copy link
Contributor

@novikor mentioned changes are ok to be added.

Risky rule will be ok if a test like https://github.com/magento/magento2/blob/2.3-develop/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php#L262 is implemented for php-cs-fixer.

@sivaschenko
Copy link
Member

@orlangur @novikor actually I am concerned about forcing developers to use "allow-risky" option in order to be able to run cs fixer using the default profile.

@orlangur
Copy link
Contributor

@sivaschenko ok, agree, although relying on operator precedence does not look like a realistic scenario such developer experience would be pretty confusing. We may use risky fixers for dry run mode only when we have a php-cs-fixer test.

@novikor feel free to contribute phpcs rule only and php-cs-fixer test may be contributed as a separate improvement.

@novikor novikor force-pushed the Static-tests-forbid-or-instead-of-21062 branch 2 times, most recently from 2cfc5bc to 2b06a7f Compare February 26, 2019 12:49
@novikor
Copy link
Contributor Author

novikor commented Feb 26, 2019

@orlangur , I decided to improve phpcs only. Please review.
image

@@ -85,4 +85,8 @@
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<rule ref="Squiz.Functions.GlobalFunction"/>
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="Squiz.Operators.ValidLogicalOperators">
<severity>6</severity>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to spoil core coding standard with severities, each rule is mandatory.

Please put it before previous line to preserve alphabetical order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to make it warning, any rule is mandatory. Please squash into one commit.

Added Squiz.Operators.ValidLogicalOperators rule
@novikor novikor force-pushed the Static-tests-forbid-or-instead-of-21062 branch from c60ed54 to 23f415a Compare March 1, 2019 15:02
@novikor
Copy link
Contributor Author

novikor commented Mar 1, 2019

No need to make it warning, any rule is mandatory. Please squash into one commit.

Done)

@magento-engcom-team
Copy link
Contributor

Hi @orlangur, thank you for the review.
ENGCOM-4300 has been created to process this Pull Request

@ghost
Copy link

ghost commented Mar 4, 2019

Hi @novikor, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.2 milestone Mar 4, 2019
@novikor novikor deleted the Static-tests-forbid-or-instead-of-21062 branch March 4, 2019 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Award: bug fix Partner: ISM eCompany Pull Request is created by partner ISM eCompany partners-contribution Pull Request is created by Magento Partner Progress: ready for testing Release Line: 2.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants