diff --git a/Magento2/Sniffs/Legacy/CopyrightAnotherExtensionsFilesSniff.php b/Magento2/Sniffs/Legacy/CopyrightAnotherExtensionsFilesSniff.php new file mode 100644 index 00000000..1455ee58 --- /dev/null +++ b/Magento2/Sniffs/Legacy/CopyrightAnotherExtensionsFilesSniff.php @@ -0,0 +1,52 @@ + 0) { + return; + } + + $fileText = $phpcsFile->getTokensAsString($stackPtr, count($phpcsFile->getTokens())); + $adobeCopyrightFound = preg_match(self::COPYRIGHT_ADOBE, $fileText); + + if (strpos($fileText, self::COPYRIGHT_MAGENTO_TEXT) !== false || $adobeCopyrightFound) { + return; + } + + $phpcsFile->addWarningOnLine( + 'Copyright is missing or has wrong format', + null, + self::WARNING_CODE + ); + } +} diff --git a/Magento2/Tests/Legacy/AbstractJsSniffUnitTestCase.php b/Magento2/Tests/Legacy/AbstractJsSniffUnitTestCase.php new file mode 100644 index 00000000..4b891a3c --- /dev/null +++ b/Magento2/Tests/Legacy/AbstractJsSniffUnitTestCase.php @@ -0,0 +1,33 @@ +extensions = array_merge( + $config->extensions, + [ + 'js' => 'PHP' + ] + ); + + $GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config; + } +} diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.1.xml b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.1.xml new file mode 100644 index 00000000..5bbf8807 --- /dev/null +++ b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.1.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.2.js b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.2.js new file mode 100644 index 00000000..511f7b94 --- /dev/null +++ b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.2.js @@ -0,0 +1,10 @@ +/** + * Copyright Adobe. + * See COPYING.txt for license details. + */ + +define([ + 'jquery' +], function (){ + +}); \ No newline at end of file diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.4.js b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.4.js new file mode 100644 index 00000000..2eb60f49 --- /dev/null +++ b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.4.js @@ -0,0 +1,10 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery' +], function (){ + +}); \ No newline at end of file diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.php b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.php new file mode 100644 index 00000000..8796abb9 --- /dev/null +++ b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.php @@ -0,0 +1,41 @@ + 1, + ]; + } + if ($testFile === 'CopyrightAnotherExtensionsFilesUnitTest.2.js') { + return [ + null => 1, + ]; + } + if ($testFile === 'CopyrightAnotherExtensionsFilesUnitTest.3.xml') { + return []; + } + if ($testFile === 'CopyrightAnotherExtensionsFilesUnitTest.4.js') { + return []; + } + return []; + } +} diff --git a/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.xml b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.xml new file mode 100644 index 00000000..d1dcf359 --- /dev/null +++ b/Magento2/Tests/Legacy/CopyrightAnotherExtensionsFilesUnitTest.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index b8e2742f..212bf246 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -3,7 +3,7 @@ Magento Coding Standard - + @@ -634,6 +634,10 @@ */Test/* *Test.php + + 5 + warning + 5 warning