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

[Dev][Coding Standard] Hundreds of PHPCS-based static tests violations in mainline #8612

Closed
orlangur opened this issue Feb 20, 2017 · 5 comments
Labels
Component: multiple Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P4 No current plan to fix. Fixing can be deferred as a logical part of more important work. Progress: done Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. stale issue

Comments

@orlangur
Copy link
Contributor

This issue is NOT about @codingStandardsIgnoreFile evil annotation appearing quite often: http://prnt.sc/eawtih
The problem is that even except those 666 ignored files there are a lot of not coding standard compliant files due to holes in CI processes and/or bugs in get_changed_files mechanism. This is even more strange as "bump copyright year" commit changed all the files and still didn't reveal these violations.

Preconditions

Use develop branch

Steps to reproduce

Run PHPCS-based tests against full codebase

Expected result

PHPCS-based tests are green

Actual result

https://travis-ci.org/orlangur/magento2/jobs/203250472

1) Magento\Test\Php\LiveCodeTest::testCodeStylePsr2
PHP Code Sniffer has found 16 error(s):
2) Magento\Test\Php\LiveCodeTest::testCodeStyle
PHP Code Sniffer has found 176 error(s): 
3) Magento\Test\Php\LiveCodeTest::testAnnotationStandard
PHP Code Sniffer has found 168 error(s): 

Solution

As it turned out, running PHPCS against full codebase takes less than 5 minutes: https://travis-ci.org/orlangur/magento2/jobs/203222909#L554

I propose to remove buggy get_changed_files mechanism for PHPCS-based tests as it does not bring any notable value currently but causes troubles.

I would like to prepare a pull request implementing this approach and eliminating all existing violations if you don't mind.

orlangur added a commit to orlangur/magento2 that referenced this issue Feb 26, 2017
…ests violations in mainline

- enable PHPCS-based tests for the whole codebase
- combine three PHPCS-based tests into one
- polish up Magento Coding Standard into one ruleset.xml: no new rules added, only those rules removed which are already contained in PSR2
- run static tests under PHP 7 which is ~3 times faster than PHP 5.6
orlangur added a commit to orlangur/magento2 that referenced this issue Feb 26, 2017
…ests violations in mainline

- apply manual fixes to make PHPCS happy, changes for "Constants are not allowed as the first argument of translation function, use string literal instead"
- third-party constants are simply ignored, not sure if this is correct or not
orlangur added a commit to orlangur/magento2 that referenced this issue Feb 26, 2017
…ests violations in mainline

- apply manual fixes to make PHPCS and PHPMD happy
- some phtml templates marked as ignored for now as PHPCS 1.5.3 version produces false-positives on them (PHPCS 2.8.0 treats them fine)
orlangur added a commit to orlangur/magento2 that referenced this issue Feb 26, 2017
…ests violations in mainline

- apply automatic PHP-CS-FIXER fixes to make PHPCS happy
- Step 0. Install php-cs-fixer globally: composer global require friendsofphp/php-cs-fixer:2.1.0
- Step 1. Remove outdated php-cs-fixer config: rm .php_cs
- Step 2. Execute tool: ~/.composer/vendor/bin/php-cs-fixer fix . --rules=no_extra_consecutive_blank_lines,method_separation -v
- Step 3. Reset changed fixture file to not break related unit test: git checkout HEAD -- lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php
- Step 4. Restore outdated php-cs-fixer config: git checkout HEAD -- .php_cs
orlangur added a commit to orlangur/magento2 that referenced this issue Feb 26, 2017
…ests violations in mainline

- apply automatic PHPCBF fixes to make PHPCS happy
- Step 0. Install phpcs globally: composer global require squizlabs/php_codesniffer:2.8.0
- Step 1. Execute tool to fix PSR-2 violations in PHP files: ~/.composer/vendor/bin/phpcbf --standard=PSR2 --extensions=php --ignore=generated/*,vendor/*,var/* .
orlangur added a commit to orlangur/magento2 that referenced this issue Feb 26, 2017
…ests violations in mainline

- apply manual fixes to make PHPCS and PHPMD happy
orlangur added a commit to orlangur/magento2 that referenced this issue Mar 11, 2017
…ests violations in mainline

- apply manual fixes to make PHPCS happy, changes for "Constants are not allowed as the first argument of translation function, use string literal instead"
- third-party constants are simply ignored, not sure if this is correct or not
orlangur added a commit to orlangur/magento2 that referenced this issue Mar 11, 2017
…ests violations in mainline

- apply manual fixes to make PHPCS and PHPMD happy
- some phtml templates marked as ignored for now as PHPCS 1.5.3 version produces false-positives on them (PHPCS 2.8.0 treats them fine)
orlangur added a commit to orlangur/magento2 that referenced this issue Mar 11, 2017
…ests violations in mainline

- apply automatic PHP-CS-FIXER fixes to make PHPCS happy
- Step 0. Install php-cs-fixer globally: composer global require friendsofphp/php-cs-fixer:2.1.0
- Step 1. Remove outdated php-cs-fixer config: rm .php_cs
- Step 2. Execute tool: ~/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix . --rules=no_extra_consecutive_blank_lines,method_separation -v
- Step 3. Reset changed fixture file to not break related unit test: git checkout HEAD -- lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php
- Step 4. Restore outdated php-cs-fixer config: git checkout HEAD -- .php_cs
orlangur added a commit to orlangur/magento2 that referenced this issue Mar 11, 2017
…ests violations in mainline

- apply automatic PHPCBF fixes to make PHPCS happy
- Step 0. Install phpcs globally: composer global require squizlabs/php_codesniffer:2.8.0
- Step 1. Execute tool to fix PSR-2 violations in PHP files: ~/.composer/vendor/squizlabs/php_codesniffer/scripts/phpcbf --standard=PSR2 --extensions=php --ignore=generated/*,vendor/*,var/* .
orlangur added a commit to orlangur/magento2 that referenced this issue Mar 11, 2017
…ests violations in mainline

- apply manual fixes to make PHPCS and PHPMD happy
magento-team pushed a commit that referenced this issue Mar 15, 2017
… PHPCS-based static tests violations in mainline #8685

 - Merge Pull Request #8685 from orlangur/magento2:phpcs-tests-refactoring
magento-team pushed a commit that referenced this issue Mar 15, 2017
… PHPCS-based static tests violations in mainline #8685
magento-team pushed a commit that referenced this issue Mar 15, 2017
… PHPCS-based static tests violations in mainline #8685

 - fixed code style issues
magento-team pushed a commit that referenced this issue Mar 15, 2017
… PHPCS-based static tests violations in mainline #8685

 - fixed whitelist for cs test
magento-team pushed a commit that referenced this issue Mar 15, 2017
… PHPCS-based static tests violations in mainline #8685

 - fixed code style issue
magento-team pushed a commit that referenced this issue Oct 5, 2017
… PHPCS-based static tests violations in mainline #8685

 - automatic fix of code style issues:
    - Step 1. Install php-cs-fixer globally: composer global require friendsofphp/php-cs-fixer:2.1.0
    - Step 2. Execute tool: ~/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix . --rules=no_extra_consecutive_blank_lines,method_separation -v
magento-team pushed a commit that referenced this issue Oct 5, 2017
… PHPCS-based static tests violations in mainline #8685

 - automatic fix of code style issues:
    - Step 1. Install phpcs globally: composer global require squizlabs/php_codesniffer:2.8.0
    - Step 1. Execute tool to fix PSR-2 violations in PHP files: ~/.composer/vendor/squizlabs/php_codesniffer/scripts/phpcbf --standard=PSR2 --extensions=php --ignore=generated/*,vendor/*,var/* .
magento-engcom-team pushed a commit that referenced this issue Mar 16, 2018
… PHPCS-based static tests violations in mainline #8685

 - automatic fix of code style issues:
    - Step 1. Install php-cs-fixer globally: composer global require friendsofphp/php-cs-fixer:2.1.0
    - Step 2. Execute tool: ~/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix . --rules=no_extra_consecutive_blank_lines,method_separation -v
magento-engcom-team pushed a commit that referenced this issue Mar 16, 2018
… PHPCS-based static tests violations in mainline #8685

 - automatic fix of code style issues:
    - Step 1. Install phpcs globally: composer global require squizlabs/php_codesniffer:2.8.0
    - Step 1. Execute tool to fix PSR-2 violations in PHP files: ~/.composer/vendor/squizlabs/php_codesniffer/scripts/phpcbf --standard=PSR2 --extensions=php --ignore=generated/*,vendor/*,var/* .
magento-engcom-team pushed a commit that referenced this issue Mar 16, 2018
… PHPCS-based static tests violations in mainline #8685

 - automatic fix of code style issues:
    - Step 1. Install phpcs globally: composer global require squizlabs/php_codesniffer:2.8.0
    - Step 1. Execute tool to fix PSR-2 violations in PHP files: ~/.composer/vendor/squizlabs/php_codesniffer/scripts/phpcbf --standard=PSR2 --extensions=php --ignore=generated/*,vendor/*,var/* .
@orlangur
Copy link
Contributor Author

Regression occurred. Looks like Magento\Test\Php\LiveCodeTest is now broken and does not check against the full codebase.

Steps to reproduce

Run ./vendor/bin/phpcs --standard=dev/tests/static/framework/Magento/ruleset.xml {app,dev,lib/internal} -n --extensions=php,phtml --report=json | less

Expected result

PHPCS-based tests are green

Actual result

{"totals":{"errors":21638,"warnings":0,"fixable":21467}

What needs to be done

  1. Fix phpcs-based static test so that it is checking the full codebase again
  2. Eliminate coding style violations

I'm going to take care of it this weekend or earlier if I have some spare time.

@orlangur orlangur reopened this Dec 19, 2018
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 19, 2018
@orlangur orlangur self-assigned this Dec 19, 2018
@orlangur orlangur added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed labels Dec 19, 2018
orlangur added a commit to orlangur/magento2 that referenced this issue Dec 19, 2018
@okorshenko
Copy link
Contributor

Hi @orlangur
Thank you for working on this. We are looking for your PR

@orlangur orlangur added this to the Release: 2.3.3 milestone Jun 4, 2019
@sidolov sidolov removed this from the Release: 2.3.3 milestone Aug 6, 2019
@ghost ghost unassigned orlangur Sep 27, 2019
@ghost ghost removed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 20, 2020
@magento-engcom-team magento-engcom-team added Priority: P4 No current plan to fix. Fixing can be deferred as a logical part of more important work. Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. labels Nov 30, 2020
@stale
Copy link

stale bot commented Feb 14, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: multiple Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P4 No current plan to fix. Fixing can be deferred as a logical part of more important work. Progress: done Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. stale issue
Projects
Development

No branches or pull requests

5 participants