From c38ca663482bb17cae91e66b78f0ac544fe3e65d Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Thu, 14 Oct 2021 15:25:33 +0200 Subject: [PATCH 1/8] AC-206: Create UCT phpcs ruleset for customizations only --- Magento2/customizations-ruleset.xml | 719 ++++++++++++++++++++++++++++ 1 file changed, 719 insertions(+) create mode 100644 Magento2/customizations-ruleset.xml diff --git a/Magento2/customizations-ruleset.xml b/Magento2/customizations-ruleset.xml new file mode 100644 index 00000000..2c7c695c --- /dev/null +++ b/Magento2/customizations-ruleset.xml @@ -0,0 +1,719 @@ + + + Magento Coding Standard + + + + + + + 10 + error + + + 10 + error + *\.phtml$ + *\.xml$ + + + 10 + error + *\.xml$ + + + 10 + error + */lib/* + *\.xml$ + + + 10 + error + *\.xml$ + + + 10 + error + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + + + 10 + error + + + 10 + error + + + 10 + error + *\.xml$ + + + 10 + error + *\.xml$ + + + 10 + error + *\.xml$ + + + 10 + error + */_files/* + */Fixtures/* + */lib/* + */Test/* + *Test.php + */tests/* + + + 10 + error + + + 10 + error + + + *\.phtml$ + + + 10 + error + */_files/* + */Fixtures/* + */lib/* + */Test/* + *Test.php + */tests/* + + + 10 + error + + + 10 + error + + + 10 + error + *\.phtml$ + + + 10 + error + *\.xml$ + + + 10 + error + + + 10 + error + + + etc/config.xml + etc/config.*.xml + etc/*/config.xml + 10 + error + + + 10 + error + + + *\.php$ + 10 + error + + + 10 + error + *\.xml$ + + + 10 + error + */view/(adminhtml|frontend|base)/*\/.xml + + + 10 + error + *\.xml$ + *\.js$ + + + *\/etc/*.xml$ + *\/etc/wsdl.xml$ + *\/etc/wsdl2.xml$ + *\/etc/wsi.xml$ + 10 + error + + + + 9 + warning + + + 9 + warning + */_files/* + */Fixtures/* + */lib/* + */Test/* + *Test.php + */tests/* + + + *\.phtml$ + 9 + warning + + + 9 + warning + */_files/* + */Fixtures/* + */lib/* + */Test/* + *Test.php + */tests/* + + + 9 + warning + *\.xml$ + + + *\/.phtml$ + 9 + warning + *\.xml$ + + + + + 8 + warning + + + 8 + warning + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + + + 8 + warning + + + 8 + warning + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + + + 8 + warning + */_files/* + */Fixtures/* + */lib/* + */Test/* + *Test.php + */tests/* + + + 8 + warning + */_files/* + */Fixtures/* + */lib/* + */Setup/* + */Test/* + *Test.php + */tests/* + + + 8 + warning + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + + + 8 + warning + + + 8 + warning + *\.xml$ + + + *\.phtml$ + 8 + warning + + + 8 + warning + + + 8 + warning + + + *\/module.xml$ + 8 + warning + + + *\/di.xml$ + 8 + warning + + + 8 + warning + *\.xml$ + + + *\/widget.xml$ + 8 + warning + + + etc/config.xml + etc/config.*.xml + etc/*/config.xml + 8 + warning + + + etc/config.xml + etc/config.*.xml + etc/*/config.xml + 8 + warning + + + etc/adminhtml/system.xml + 8 + warning + + + *\.phtml$ + 8 + warning + + + + 7 + warning + + + 7 + warning + + + 7 + warning + + + 7 + warning + + + 7 + warning + + + 7 + warning + + + 7 + warning + + + 7 + warning + + + *\.xml$ + 7 + warning + + + 0 + + + 7 + warning + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + + + 7 + warning + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + *\.xml$ + + + 7 + warning + *\.xml$ + + + 7 + warning + + + 7 + warning + + + 7 + warning + + + 7 + warning + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + + + 7 + warning + *\.phtml$ + + + 7 + warning + + + 7 + warning + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + *\.xml$ + + + 7 + warning + + + + + 6 + warning + + + 6 + warning + + + + + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + *\.xml$ + + + 6 + warning + *\.xml$ + + + 6 + warning + + + + + + + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + + 0 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + *\.phtml$ + + + 6 + warning + */_files/* + */Fixtures/* + */Test/* + *Test.php + */tests/* + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 0 + + + 0 + + + 6 + warning + + + 6 + warning + + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + + + + *\.phtml$ + + + 6 + warning + + + 0 + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + + + + 0 + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + + + 6 + warning + *\.phtml$ + + + 6 + warning + + + + + + 6 + warning + + + 6 + warning + + + 6 + warning + *\.less$ + + + 0 + + + 0 + + + 0 + + + + + 5 + warning + + + 5 + warning + + + 5 + warning + + + 5 + warning + + + + + + 5 + warning + *\.xml$ + + + 5 + warning + */_files/* + */Test/* + *Test.php + + + 0 + + From 90983fbddf5e28c7c29cde5153dee707ffbca81e Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Thu, 14 Oct 2021 15:27:20 +0200 Subject: [PATCH 2/8] AC-206: Create UCT phpcs ruleset for customizations only --- Magento2/customizations-ruleset.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Magento2/customizations-ruleset.xml b/Magento2/customizations-ruleset.xml index 2c7c695c..e6820cc9 100644 --- a/Magento2/customizations-ruleset.xml +++ b/Magento2/customizations-ruleset.xml @@ -1,6 +1,6 @@ - - Magento Coding Standard + + Magento Coding Standard for customizations From 30a34f2bebe241c5c301b2a2bb6bfed94f4b4e5e Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko Date: Tue, 19 Oct 2021 12:38:16 +0100 Subject: [PATCH 3/8] AC-206: Updated and renamed the extesnions-ruleset.xml --- ...customizations-ruleset.xml => extensions-ruleset.xml} | 9 +++++++++ 1 file changed, 9 insertions(+) rename Magento2/{customizations-ruleset.xml => extensions-ruleset.xml} (99%) diff --git a/Magento2/customizations-ruleset.xml b/Magento2/extensions-ruleset.xml similarity index 99% rename from Magento2/customizations-ruleset.xml rename to Magento2/extensions-ruleset.xml index e6820cc9..c626c5ab 100644 --- a/Magento2/customizations-ruleset.xml +++ b/Magento2/extensions-ruleset.xml @@ -326,6 +326,15 @@ 8 warning + + 8 + warning + + + 8 + warning + + 7 From 655960e8144e2dfedf0d58a76e9d3dbd4ecba4c1 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko Date: Tue, 19 Oct 2021 13:19:32 +0100 Subject: [PATCH 4/8] AC-206: Added Magento only ruleset --- Magento2/extensions-ruleset.xml | 728 ------------------------------ Magento2/magento-only-ruleset.xml | 16 + Magento2/ruleset.xml | 17 - 3 files changed, 16 insertions(+), 745 deletions(-) delete mode 100644 Magento2/extensions-ruleset.xml create mode 100644 Magento2/magento-only-ruleset.xml diff --git a/Magento2/extensions-ruleset.xml b/Magento2/extensions-ruleset.xml deleted file mode 100644 index c626c5ab..00000000 --- a/Magento2/extensions-ruleset.xml +++ /dev/null @@ -1,728 +0,0 @@ - - - Magento Coding Standard for customizations - - - - - - - 10 - error - - - 10 - error - *\.phtml$ - *\.xml$ - - - 10 - error - *\.xml$ - - - 10 - error - */lib/* - *\.xml$ - - - 10 - error - *\.xml$ - - - 10 - error - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - - - 10 - error - - - 10 - error - - - 10 - error - *\.xml$ - - - 10 - error - *\.xml$ - - - 10 - error - *\.xml$ - - - 10 - error - */_files/* - */Fixtures/* - */lib/* - */Test/* - *Test.php - */tests/* - - - 10 - error - - - 10 - error - - - *\.phtml$ - - - 10 - error - */_files/* - */Fixtures/* - */lib/* - */Test/* - *Test.php - */tests/* - - - 10 - error - - - 10 - error - - - 10 - error - *\.phtml$ - - - 10 - error - *\.xml$ - - - 10 - error - - - 10 - error - - - etc/config.xml - etc/config.*.xml - etc/*/config.xml - 10 - error - - - 10 - error - - - *\.php$ - 10 - error - - - 10 - error - *\.xml$ - - - 10 - error - */view/(adminhtml|frontend|base)/*\/.xml - - - 10 - error - *\.xml$ - *\.js$ - - - *\/etc/*.xml$ - *\/etc/wsdl.xml$ - *\/etc/wsdl2.xml$ - *\/etc/wsi.xml$ - 10 - error - - - - 9 - warning - - - 9 - warning - */_files/* - */Fixtures/* - */lib/* - */Test/* - *Test.php - */tests/* - - - *\.phtml$ - 9 - warning - - - 9 - warning - */_files/* - */Fixtures/* - */lib/* - */Test/* - *Test.php - */tests/* - - - 9 - warning - *\.xml$ - - - *\/.phtml$ - 9 - warning - *\.xml$ - - - - - 8 - warning - - - 8 - warning - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - - - 8 - warning - - - 8 - warning - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - - - 8 - warning - */_files/* - */Fixtures/* - */lib/* - */Test/* - *Test.php - */tests/* - - - 8 - warning - */_files/* - */Fixtures/* - */lib/* - */Setup/* - */Test/* - *Test.php - */tests/* - - - 8 - warning - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - - - 8 - warning - - - 8 - warning - *\.xml$ - - - *\.phtml$ - 8 - warning - - - 8 - warning - - - 8 - warning - - - *\/module.xml$ - 8 - warning - - - *\/di.xml$ - 8 - warning - - - 8 - warning - *\.xml$ - - - *\/widget.xml$ - 8 - warning - - - etc/config.xml - etc/config.*.xml - etc/*/config.xml - 8 - warning - - - etc/config.xml - etc/config.*.xml - etc/*/config.xml - 8 - warning - - - etc/adminhtml/system.xml - 8 - warning - - - *\.phtml$ - 8 - warning - - - 8 - warning - - - 8 - warning - - - - - 7 - warning - - - 7 - warning - - - 7 - warning - - - 7 - warning - - - 7 - warning - - - 7 - warning - - - 7 - warning - - - 7 - warning - - - *\.xml$ - 7 - warning - - - 0 - - - 7 - warning - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - - - 7 - warning - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - *\.xml$ - - - 7 - warning - *\.xml$ - - - 7 - warning - - - 7 - warning - - - 7 - warning - - - 7 - warning - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - - - 7 - warning - *\.phtml$ - - - 7 - warning - - - 7 - warning - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - *\.xml$ - - - 7 - warning - - - - - 6 - warning - - - 6 - warning - - - - - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - *\.xml$ - - - 6 - warning - *\.xml$ - - - 6 - warning - - - - - - - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - - 0 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - *\.phtml$ - - - 6 - warning - */_files/* - */Fixtures/* - */Test/* - *Test.php - */tests/* - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 0 - - - 0 - - - 6 - warning - - - 6 - warning - - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - - - - *\.phtml$ - - - 6 - warning - - - 0 - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - - - - 0 - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - - - 6 - warning - *\.phtml$ - - - 6 - warning - - - - - - 6 - warning - - - 6 - warning - - - 6 - warning - *\.less$ - - - 0 - - - 0 - - - 0 - - - - - 5 - warning - - - 5 - warning - - - 5 - warning - - - 5 - warning - - - - - - 5 - warning - *\.xml$ - - - 5 - warning - */_files/* - */Test/* - *Test.php - - - 0 - - diff --git a/Magento2/magento-only-ruleset.xml b/Magento2/magento-only-ruleset.xml new file mode 100644 index 00000000..6a81cd26 --- /dev/null +++ b/Magento2/magento-only-ruleset.xml @@ -0,0 +1,16 @@ + + + Magento Coding Standard sniffs applicable for Magento Open Source development only + + 5 + warning + *\.php$ + *\.phtml$ + + + 5 + warning + *\.php$ + *\.phtml$ + + diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index ffe71710..1b55a9ad 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -726,24 +726,7 @@ */Test/* *Test.php - - 5 - warning - *\.php$ - *\.phtml$ - - - 5 - warning - *\.php$ - *\.phtml$ - 0 - - - - - From c0d26b8dc249ba5b8e7820e8c77743e6bff4f32f Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko Date: Tue, 19 Oct 2021 13:25:04 +0100 Subject: [PATCH 5/8] AC-206: Moved License sniff to magento-only-ruleset --- Magento2/magento-only-ruleset.xml | 8 ++++++-- Magento2/ruleset.xml | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Magento2/magento-only-ruleset.xml b/Magento2/magento-only-ruleset.xml index 6a81cd26..fbbe1ba5 100644 --- a/Magento2/magento-only-ruleset.xml +++ b/Magento2/magento-only-ruleset.xml @@ -1,13 +1,17 @@ Magento Coding Standard sniffs applicable for Magento Open Source development only - + + 5 + warning + + 5 warning *\.php$ *\.phtml$ - + 5 warning *\.php$ diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index 1b55a9ad..442d9867 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -334,10 +334,6 @@ 8 warning - - 8 - warning - From c7250a26de1b7a54bc7880338c08564146e96d36 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko Date: Tue, 19 Oct 2021 13:36:17 +0100 Subject: [PATCH 6/8] AC-206: Corrected rules names in magento-only-ruleset --- Magento2/magento-only-ruleset.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Magento2/magento-only-ruleset.xml b/Magento2/magento-only-ruleset.xml index fbbe1ba5..bace947f 100644 --- a/Magento2/magento-only-ruleset.xml +++ b/Magento2/magento-only-ruleset.xml @@ -1,17 +1,17 @@ Magento Coding Standard sniffs applicable for Magento Open Source development only - + 5 warning - + 5 warning *\.php$ *\.phtml$ - + 5 warning *\.php$ From 88d9f59ec7844e4b2ef57bb65219228b891bb53b Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko Date: Tue, 19 Oct 2021 14:25:17 +0100 Subject: [PATCH 7/8] AC-206: Extracted Fframework only sniffs to a separate namespace --- .github/workflows/php.yml | 5 ++- .../Sniffs/Legacy/RestrictedCodeSniff.php | 37 ++----------------- .../Legacy/_files/restricted_classes.php | 13 +++++-- .../Legacy/_files/restricted_classes_ee.php | 32 ---------------- .../Legacy/AbstractJsSniffUnitTestCase.php | 33 ----------------- .../CopyrightAnotherExtensionsFilesSniff.php | 6 +-- .../Sniffs/Header}/CopyrightSniff.php | 8 ++-- .../Sniffs/Header}/LicenseSniff.php | 10 ++--- ...yrightAnotherExtensionsFilesUnitTest.1.xml | 0 ...pyrightAnotherExtensionsFilesUnitTest.2.js | 0 ...yrightAnotherExtensionsFilesUnitTest.3.xml | 0 ...pyrightAnotherExtensionsFilesUnitTest.4.js | 0 ...rightAnotherExtensionsFilesUnitTest.5.less | 0 ...opyrightAnotherExtensionsFilesUnitTest.php | 25 ++++++++++++- .../Tests/Header}/CopyrightUnitTest.1.inc | 0 .../Tests/Header}/CopyrightUnitTest.2.inc | 0 .../Tests/Header}/CopyrightUnitTest.3.inc | 0 .../Tests/Header}/CopyrightUnitTest.4.inc | 0 .../Tests/Header}/CopyrightUnitTest.5.inc | 0 .../Tests/Header}/CopyrightUnitTest.php | 4 +- .../Tests/Header}/LicenseUnitTest.1.inc | 0 .../Tests/Header}/LicenseUnitTest.2.inc | 0 .../Tests/Header}/LicenseUnitTest.3.xml | 0 .../Tests/Header}/LicenseUnitTest.4.xml | 0 .../Tests/Header}/LicenseUnitTest.5.less | 0 .../Tests/Header}/LicenseUnitTest.php | 4 +- .../ruleset.xml | 10 ++--- composer.json | 3 +- composer.lock | 11 +++--- 29 files changed, 69 insertions(+), 132 deletions(-) delete mode 100644 Magento2/Sniffs/Legacy/_files/restricted_classes_ee.php delete mode 100644 Magento2/Tests/Legacy/AbstractJsSniffUnitTestCase.php rename {Magento2/Sniffs/Legacy => Magento2Framework/Sniffs/Header}/CopyrightAnotherExtensionsFilesSniff.php (96%) rename {Magento2/Sniffs/Legacy => Magento2Framework/Sniffs/Header}/CopyrightSniff.php (96%) rename {Magento2/Sniffs/Legacy => Magento2Framework/Sniffs/Header}/LicenseSniff.php (97%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightAnotherExtensionsFilesUnitTest.1.xml (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightAnotherExtensionsFilesUnitTest.2.js (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightAnotherExtensionsFilesUnitTest.3.xml (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightAnotherExtensionsFilesUnitTest.4.js (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightAnotherExtensionsFilesUnitTest.5.less (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightAnotherExtensionsFilesUnitTest.php (64%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightUnitTest.1.inc (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightUnitTest.2.inc (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightUnitTest.3.inc (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightUnitTest.4.inc (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightUnitTest.5.inc (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/CopyrightUnitTest.php (95%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/LicenseUnitTest.1.inc (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/LicenseUnitTest.2.inc (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/LicenseUnitTest.3.xml (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/LicenseUnitTest.4.xml (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/LicenseUnitTest.5.less (100%) rename {Magento2/Tests/Legacy => Magento2Framework/Tests/Header}/LicenseUnitTest.php (95%) rename Magento2/magento-only-ruleset.xml => Magento2Framework/ruleset.xml (59%) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 66010067..7e64fe7a 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -59,4 +59,7 @@ jobs: run: vendor/bin/phpunit - name: Run code style suite - run: vendor/bin/phpcs --standard=Magento2 Magento2/Helpers/ Magento2/Sniffs + run: vendor/bin/phpcs --standard=Magento2 Magento2/Helpers Magento2/Sniffs Magento2Framework/Sniffs + + - name: Run framework suite + run: vendor/bin/phpcs --standard=Magento2Framework Magento2/Helpers Magento2/Sniffs Magento2Framework/Sniffs diff --git a/Magento2/Sniffs/Legacy/RestrictedCodeSniff.php b/Magento2/Sniffs/Legacy/RestrictedCodeSniff.php index a0c0113f..62ee2d4e 100644 --- a/Magento2/Sniffs/Legacy/RestrictedCodeSniff.php +++ b/Magento2/Sniffs/Legacy/RestrictedCodeSniff.php @@ -37,7 +37,8 @@ class RestrictedCodeSniff implements Sniff */ public function __construct() { - $this->loadData('restricted_classes*.php'); + // phpcs:ignore Magento2.Security.IncludeFile.FoundIncludeFile + $this->classes = include __DIR__ . '/_files/restricted_classes.php'; } /** @@ -56,7 +57,7 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { - // phpcs:ignore + // phpcs:ignore Magento2.Functions.DiscouragedFunction if (array_key_exists(basename($phpcsFile->getFilename()), $this->fixtureFiles)) { return; } @@ -99,36 +100,4 @@ private function isExcluded(string $token, File $phpcsFile): bool } return false; } - - /** - * Loads and merges data from fixtures - * - * @param string $filePattern - * @return void - */ - private function loadData(string $filePattern) - { - // phpcs:ignore - foreach (glob(__DIR__ . '/_files/' . $filePattern) as $file) { - $relativePath = str_replace( - '\\', - '/', - str_replace(__DIR__ . DIRECTORY_SEPARATOR, '', $file) - ); - array_push($this->fixtureFiles, $relativePath); - $this->classes = array_merge_recursive($this->classes, $this->readList($file)); - } - } - - /** - * Isolate including a file into a method to reduce scope - * - * @param string $file - * @return array - */ - private function readList($file) - { - // phpcs:ignore - return include $file; - } } diff --git a/Magento2/Sniffs/Legacy/_files/restricted_classes.php b/Magento2/Sniffs/Legacy/_files/restricted_classes.php index 56a2e510..1052b994 100644 --- a/Magento2/Sniffs/Legacy/_files/restricted_classes.php +++ b/Magento2/Sniffs/Legacy/_files/restricted_classes.php @@ -17,7 +17,8 @@ 'exclude' => [ 'Magento/Framework/DB/Select.php', 'Magento/Framework/DB/Adapter/Pdo/Mysql.php', - 'Magento/Framework/Model/ResourceModel/Iterator.php' + 'Magento/Framework/Model/ResourceModel/Iterator.php', + 'Magento/ResourceConnections/DB/Adapter/Pdo/MysqlProxy.php' ] ], 'Zend_Db_Adapter_Pdo_Mysql' => [ @@ -48,7 +49,10 @@ 'Magento/Framework/Flag.php', 'Magento/Widget/Setup/LayoutUpdateConverter.php', 'Magento/Cms/Setup/ContentConverter.php', - 'Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php' + 'Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php', + 'Magento/Framework/Test/Unit/FlagTest.php', + 'Magento/Staging/Test/Unit/Model/Update/FlagTest.php', + 'Magento/Logging/Test/Unit/Setup/ObjectConverterTest.php' ] ], 'ArrayObject' => [ @@ -67,7 +71,10 @@ 'Magento/Framework/Indexer/Test/Unit/BatchTest.php', 'Magento/Framework/View/Element/UiComponent/ArrayObjectFactory.php', 'Magento/Framework/View/Element/UiComponent/Config/Provider/Component/Definition.php', - 'Magento/Framework/Indexer/Action/Base.php' + 'Magento/Framework/Indexer/Action/Base.php', + 'Magento/MultipleWishlist/Test/Unit/Model/Search/Strategy/EmailTest.php', + 'Magento/Rma/Test/Unit/Model/RmaRepositoryTest.php', + 'Magento/Rma/Test/Unit/Model/Status/HistoryRepositoryTest.php' ] ], 'Magento\Framework\View\Element\UiComponent\ArrayObjectFactory' => [ diff --git a/Magento2/Sniffs/Legacy/_files/restricted_classes_ee.php b/Magento2/Sniffs/Legacy/_files/restricted_classes_ee.php deleted file mode 100644 index 0c633bb9..00000000 --- a/Magento2/Sniffs/Legacy/_files/restricted_classes_ee.php +++ /dev/null @@ -1,32 +0,0 @@ - will be suggested to be used instead. - * Use to specify files and directories that are allowed to use restricted classes. - * - * Format: array(, [, array()]]) - * - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -return [ - 'Zend_Db_Select' => [ - 'exclude' => [ - 'Magento/ResourceConnections/DB/Adapter/Pdo/MysqlProxy.php' - ], - ], - 'Magento\Framework\Serialize\Serializer\Serialize' => [ - 'exclude' => [ - 'Magento/Framework/Test/Unit/FlagTest.php', - 'Magento/Staging/Test/Unit/Model/Update/FlagTest.php', - 'Magento/Logging/Test/Unit/Setup/ObjectConverterTest.php' - ] - ], - 'ArrayObject' => [ - 'exclude' => [ - 'Magento/MultipleWishlist/Test/Unit/Model/Search/Strategy/EmailTest.php', - 'Magento/Rma/Test/Unit/Model/RmaRepositoryTest.php', - 'Magento/Rma/Test/Unit/Model/Status/HistoryRepositoryTest.php' - ] - ] -]; diff --git a/Magento2/Tests/Legacy/AbstractJsSniffUnitTestCase.php b/Magento2/Tests/Legacy/AbstractJsSniffUnitTestCase.php deleted file mode 100644 index 4b891a3c..00000000 --- a/Magento2/Tests/Legacy/AbstractJsSniffUnitTestCase.php +++ /dev/null @@ -1,33 +0,0 @@ -extensions = array_merge( - $config->extensions, - [ - 'js' => 'PHP' - ] - ); - - $GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config; - } -} diff --git a/Magento2/Sniffs/Legacy/CopyrightAnotherExtensionsFilesSniff.php b/Magento2Framework/Sniffs/Header/CopyrightAnotherExtensionsFilesSniff.php similarity index 96% rename from Magento2/Sniffs/Legacy/CopyrightAnotherExtensionsFilesSniff.php rename to Magento2Framework/Sniffs/Header/CopyrightAnotherExtensionsFilesSniff.php index a1d6995b..bfc36afe 100644 --- a/Magento2/Sniffs/Legacy/CopyrightAnotherExtensionsFilesSniff.php +++ b/Magento2Framework/Sniffs/Header/CopyrightAnotherExtensionsFilesSniff.php @@ -5,7 +5,7 @@ */ declare(strict_types = 1); -namespace Magento2\Sniffs\Legacy; +namespace Magento2Framework\Sniffs\Header; use Magento2\Sniffs\Less\TokenizerSymbolsInterface; use PHP_CodeSniffer\Files\File; @@ -24,7 +24,7 @@ class CopyrightAnotherExtensionsFilesSniff implements Sniff * @var array */ public $supportedTokenizers = [TokenizerSymbolsInterface::TOKENIZER_CSS, 'PHP']; - + /** * @inheritDoc */ @@ -44,7 +44,7 @@ public function process(File $phpcsFile, $stackPtr) if ($stackPtr > 0) { return; } - + $fileText = $phpcsFile->getTokensAsString($stackPtr, count($phpcsFile->getTokens())); $adobeCopyrightFound = preg_match(self::COPYRIGHT_ADOBE, $fileText); diff --git a/Magento2/Sniffs/Legacy/CopyrightSniff.php b/Magento2Framework/Sniffs/Header/CopyrightSniff.php similarity index 96% rename from Magento2/Sniffs/Legacy/CopyrightSniff.php rename to Magento2Framework/Sniffs/Header/CopyrightSniff.php index f4ccd647..81442207 100644 --- a/Magento2/Sniffs/Legacy/CopyrightSniff.php +++ b/Magento2Framework/Sniffs/Header/CopyrightSniff.php @@ -5,7 +5,7 @@ */ declare(strict_types = 1); -namespace Magento2\Sniffs\Legacy; +namespace Magento2Framework\Sniffs\Header; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; @@ -13,10 +13,10 @@ class CopyrightSniff implements Sniff { private const WARNING_CODE = 'FoundCopyrightMissingOrWrongFormat'; - + private const COPYRIGHT_MAGENTO_TEXT = 'Copyright © Magento, Inc. All rights reserved.'; private const COPYRIGHT_ADOBE = '/Copyright \d+ Adobe/'; - + /** * @inheritdoc */ @@ -24,7 +24,7 @@ public function register() { return [T_OPEN_TAG]; } - + /** * @inheritDoc */ diff --git a/Magento2/Sniffs/Legacy/LicenseSniff.php b/Magento2Framework/Sniffs/Header/LicenseSniff.php similarity index 97% rename from Magento2/Sniffs/Legacy/LicenseSniff.php rename to Magento2Framework/Sniffs/Header/LicenseSniff.php index c6f8ba8a..667b3b2b 100644 --- a/Magento2/Sniffs/Legacy/LicenseSniff.php +++ b/Magento2Framework/Sniffs/Header/LicenseSniff.php @@ -5,7 +5,7 @@ */ declare(strict_types = 1); -namespace Magento2\Sniffs\Legacy; +namespace Magento2Framework\Sniffs\Header; use Magento2\Sniffs\Less\TokenizerSymbolsInterface; use PHP_CodeSniffer\Files\File; @@ -21,9 +21,9 @@ class LicenseSniff implements Sniff public $supportedTokenizers = [TokenizerSymbolsInterface::TOKENIZER_CSS, 'PHP']; private const WARNING_CODE = 'FoundLegacyTextInCopyright'; - + private const LEGACY_TEXTS = ['Irubin Consulting Inc', 'DBA Varien', 'Magento Inc']; - + /** * @inheritdoc */ @@ -34,7 +34,7 @@ public function register() T_INLINE_HTML ]; } - + /** * @inheritDoc */ @@ -42,7 +42,7 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $content = null; - + if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_STRING) { $content = $tokens[$stackPtr]['content']; } diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.1.xml b/Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.1.xml similarity index 100% rename from Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.1.xml rename to Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.1.xml diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.2.js b/Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.2.js similarity index 100% rename from Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.2.js rename to Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.2.js diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.3.xml b/Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.3.xml similarity index 100% rename from Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.3.xml rename to Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.3.xml diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.4.js b/Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.4.js similarity index 100% rename from Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.4.js rename to Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.4.js diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.5.less b/Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.5.less similarity index 100% rename from Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.5.less rename to Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.5.less diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.php b/Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.php similarity index 64% rename from Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.php rename to Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.php index 4223e600..c1b06f52 100644 --- a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.php +++ b/Magento2Framework/Tests/Header/CopyrightAnotherExtensionsFilesUnitTest.php @@ -3,10 +3,31 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento2\Tests\Legacy; +namespace Magento2Framework\Tests\Header; -class CopyrightAnotherExtensionsFilesUnitTest extends AbstractJsSniffUnitTestCase +use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; + +class CopyrightAnotherExtensionsFilesUnitTest extends AbstractSniffUnitTest { + /** + * @inheritDoc + */ + protected function setUp(): void + { + parent::setUp(); + + $config = new Config(); + $config->extensions = array_merge( + $config->extensions, + [ + 'js' => 'PHP' + ] + ); + + $GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config; + } + /** * @inheritdoc */ diff --git a/Magento2/Tests/Legacy/CopyrightUnitTest.1.inc b/Magento2Framework/Tests/Header/CopyrightUnitTest.1.inc similarity index 100% rename from Magento2/Tests/Legacy/CopyrightUnitTest.1.inc rename to Magento2Framework/Tests/Header/CopyrightUnitTest.1.inc diff --git a/Magento2/Tests/Legacy/CopyrightUnitTest.2.inc b/Magento2Framework/Tests/Header/CopyrightUnitTest.2.inc similarity index 100% rename from Magento2/Tests/Legacy/CopyrightUnitTest.2.inc rename to Magento2Framework/Tests/Header/CopyrightUnitTest.2.inc diff --git a/Magento2/Tests/Legacy/CopyrightUnitTest.3.inc b/Magento2Framework/Tests/Header/CopyrightUnitTest.3.inc similarity index 100% rename from Magento2/Tests/Legacy/CopyrightUnitTest.3.inc rename to Magento2Framework/Tests/Header/CopyrightUnitTest.3.inc diff --git a/Magento2/Tests/Legacy/CopyrightUnitTest.4.inc b/Magento2Framework/Tests/Header/CopyrightUnitTest.4.inc similarity index 100% rename from Magento2/Tests/Legacy/CopyrightUnitTest.4.inc rename to Magento2Framework/Tests/Header/CopyrightUnitTest.4.inc diff --git a/Magento2/Tests/Legacy/CopyrightUnitTest.5.inc b/Magento2Framework/Tests/Header/CopyrightUnitTest.5.inc similarity index 100% rename from Magento2/Tests/Legacy/CopyrightUnitTest.5.inc rename to Magento2Framework/Tests/Header/CopyrightUnitTest.5.inc diff --git a/Magento2/Tests/Legacy/CopyrightUnitTest.php b/Magento2Framework/Tests/Header/CopyrightUnitTest.php similarity index 95% rename from Magento2/Tests/Legacy/CopyrightUnitTest.php rename to Magento2Framework/Tests/Header/CopyrightUnitTest.php index 1100bc53..065f6460 100644 --- a/Magento2/Tests/Legacy/CopyrightUnitTest.php +++ b/Magento2Framework/Tests/Header/CopyrightUnitTest.php @@ -3,7 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento2\Tests\Legacy; +namespace Magento2Framework\Tests\Header; use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; @@ -25,7 +25,7 @@ public function getWarningList($testFile = ''): array if ($testFile === 'CopyrightUnitTest.4.inc' || $testFile === 'CopyrightUnitTest.5.inc') { return []; } - + if ($testFile === 'CopyrightUnitTest.1.inc') { return [ 1 => 1, diff --git a/Magento2/Tests/Legacy/LicenseUnitTest.1.inc b/Magento2Framework/Tests/Header/LicenseUnitTest.1.inc similarity index 100% rename from Magento2/Tests/Legacy/LicenseUnitTest.1.inc rename to Magento2Framework/Tests/Header/LicenseUnitTest.1.inc diff --git a/Magento2/Tests/Legacy/LicenseUnitTest.2.inc b/Magento2Framework/Tests/Header/LicenseUnitTest.2.inc similarity index 100% rename from Magento2/Tests/Legacy/LicenseUnitTest.2.inc rename to Magento2Framework/Tests/Header/LicenseUnitTest.2.inc diff --git a/Magento2/Tests/Legacy/LicenseUnitTest.3.xml b/Magento2Framework/Tests/Header/LicenseUnitTest.3.xml similarity index 100% rename from Magento2/Tests/Legacy/LicenseUnitTest.3.xml rename to Magento2Framework/Tests/Header/LicenseUnitTest.3.xml diff --git a/Magento2/Tests/Legacy/LicenseUnitTest.4.xml b/Magento2Framework/Tests/Header/LicenseUnitTest.4.xml similarity index 100% rename from Magento2/Tests/Legacy/LicenseUnitTest.4.xml rename to Magento2Framework/Tests/Header/LicenseUnitTest.4.xml diff --git a/Magento2/Tests/Legacy/LicenseUnitTest.5.less b/Magento2Framework/Tests/Header/LicenseUnitTest.5.less similarity index 100% rename from Magento2/Tests/Legacy/LicenseUnitTest.5.less rename to Magento2Framework/Tests/Header/LicenseUnitTest.5.less diff --git a/Magento2/Tests/Legacy/LicenseUnitTest.php b/Magento2Framework/Tests/Header/LicenseUnitTest.php similarity index 95% rename from Magento2/Tests/Legacy/LicenseUnitTest.php rename to Magento2Framework/Tests/Header/LicenseUnitTest.php index edcca88e..df32d8df 100644 --- a/Magento2/Tests/Legacy/LicenseUnitTest.php +++ b/Magento2Framework/Tests/Header/LicenseUnitTest.php @@ -3,7 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento2\Tests\Legacy; +namespace Magento2Framework\Tests\Header; use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; @@ -25,7 +25,7 @@ public function getWarningList($testFile = ''): array if ($testFile === 'LicenseUnitTest.1.inc' || $testFile === 'LicenseUnitTest.3.xml') { return []; } - + if ($testFile === 'LicenseUnitTest.2.inc') { return [ 3 => 1, diff --git a/Magento2/magento-only-ruleset.xml b/Magento2Framework/ruleset.xml similarity index 59% rename from Magento2/magento-only-ruleset.xml rename to Magento2Framework/ruleset.xml index bace947f..434d10cc 100644 --- a/Magento2/magento-only-ruleset.xml +++ b/Magento2Framework/ruleset.xml @@ -1,17 +1,17 @@ - - Magento Coding Standard sniffs applicable for Magento Open Source development only - + + Magento Coding Standard sniffs applicable for the framework testing only + 5 warning - + 5 warning *\.php$ *\.phtml$ - + 5 warning *\.php$ diff --git a/composer.json b/composer.json index 9b99b887..ede320cf 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "PHP_CodeSniffer/Tokenizers/" ], "psr-4": { - "Magento2\\": "Magento2/" + "Magento2\\": "Magento2/", + "Magento2Framework\\": "Magento2Framework/" } }, "scripts": { diff --git a/composer.lock b/composer.lock index a62a83dc..0e7a89fc 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "squizlabs/php_codesniffer", - "version": "3.6.0", + "version": "3.6.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" + "reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/f268ca40d54617c6e06757f83f699775c9b3ff2e", + "reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e", "shasum": "" }, "require": { @@ -60,7 +60,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-04-09T00:54:41+00:00" + "time": "2021-10-11T04:00:11+00:00" }, { "name": "webonyx/graphql-php", @@ -1924,6 +1924,7 @@ "type": "github" } ], + "abandoned": true, "time": "2020-09-28T06:45:17+00:00" }, { From dd1e3f6d78e6c28e5ba564fd784f0cc2ee718b3d Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko Date: Tue, 19 Oct 2021 14:33:58 +0100 Subject: [PATCH 8/8] AC-206: Optimized eslint test command --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 7e64fe7a..1af77466 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -42,7 +42,7 @@ jobs: - name: Install dependencies run: npm install - name: Run ESLint - run: npm run eslint -- eslint/rules Magento2 --ignore-pattern 'Magento2/Tests/Eslint/*Test.js' + run: npm run eslint -- eslint/rules - name: Run JSCS run: npm run jscs eslint/rules Magento2