diff --git a/RoboFile.php b/RoboFile.php index a0adae46f7..5d84b40c2b 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -141,8 +141,22 @@ class RoboFile extends \Robo\Tasks { $this->_exec('vendor/bin/codecept run -g failed'); } + function qaLint() { + $this->_exec('./tasks/php_lint.sh lib/ tests/'); + } + + function qaCodeSniffer() { + $this->_exec( + './vendor/bin/phpcs '. + '--standard=./tasks/code_sniffer/MailPoet '. + '--ignore=./lib/Util/Sudzy/*,./lib/Util/CSS.php,./lib/Util/XLSXWriter.php,'. + './lib/Config/PopulatorData/Templates/* '. + 'lib/' + ); + } + protected function loadEnv() { $dotenv = new Dotenv\Dotenv(__DIR__); $dotenv->load(); } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json index b3b8f0f345..f3aef7fb6a 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,10 @@ "codegyre/robo": "*", "vlucas/phpdotenv": "*", "umpirsky/twig-gettext-extractor": "1.1.*", - "raveren/kint": "^1.0" + "raveren/kint": "^1.0", + "sebastian/phpcpd": "*", + "phpmd/phpmd": "@stable", + "squizlabs/php_codesniffer": "2.*" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 3461e0d07e..4989d128ad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "1ca212f3a40d935947bfb9aee5a159d1", - "content-hash": "a2bae80e75ebce4506fc6d7bd8394a04", + "hash": "5a9cfb9c0ba8e5091659aefbe104b17a", + "content-hash": "7a265af08be4abb586601d498fbe4374", "packages": [ { "name": "cerdic/css-tidy", @@ -1236,16 +1236,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.3.0", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "31382fef2889136415751badebbd1cb022a4ed72" + "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/31382fef2889136415751badebbd1cb022a4ed72", - "reference": "31382fef2889136415751badebbd1cb022a4ed72", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", "shasum": "" }, "require": { @@ -1261,7 +1261,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -1290,7 +1290,7 @@ "stream", "uri" ], - "time": "2016-04-13 19:56:01" + "time": "2016-06-24 23:00:38" }, { "name": "henrikbjorn/lurker", @@ -1393,6 +1393,46 @@ ], "time": "2015-11-20 12:04:31" }, + { + "name": "pdepend/pdepend", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/pdepend/pdepend.git", + "reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/b086687f3a01dc6bb92d633aef071d2c5dd0db06", + "reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06", + "shasum": "" + }, + "require": { + "php": ">=5.3.7", + "symfony/config": "^2.3.0|^3", + "symfony/dependency-injection": "^2.3.0|^3", + "symfony/filesystem": "^2.3.0|^3" + }, + "require-dev": { + "phpunit/phpunit": "^4.4.0,<4.8", + "squizlabs/php_codesniffer": "^2.0.0" + }, + "bin": [ + "src/bin/pdepend" + ], + "type": "library", + "autoload": { + "psr-4": { + "PDepend\\": "src/main/php/PDepend" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of pdepend to be handled with Composer", + "time": "2016-03-10 15:15:04" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0", @@ -1539,6 +1579,71 @@ ], "time": "2016-06-10 07:14:17" }, + { + "name": "phpmd/phpmd", + "version": "2.4.3", + "source": { + "type": "git", + "url": "https://github.com/phpmd/phpmd.git", + "reference": "2b9c2417a18696dfb578b38c116cd0ddc19b256e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/2b9c2417a18696dfb578b38c116cd0ddc19b256e", + "reference": "2b9c2417a18696dfb578b38c116cd0ddc19b256e", + "shasum": "" + }, + "require": { + "pdepend/pdepend": "^2.0.4", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0", + "squizlabs/php_codesniffer": "^2.0" + }, + "bin": [ + "src/bin/phpmd" + ], + "type": "project", + "autoload": { + "psr-0": { + "PHPMD\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Manuel Pichler", + "email": "github@manuel-pichler.de", + "homepage": "https://github.com/manuelpichler", + "role": "Project Founder" + }, + { + "name": "Other contributors", + "homepage": "https://github.com/phpmd/phpmd/graphs/contributors", + "role": "Contributors" + }, + { + "name": "Marc Würth", + "email": "ravage@bluewin.ch", + "homepage": "https://github.com/ravage84", + "role": "Project Maintainer" + } + ], + "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", + "homepage": "http://phpmd.org/", + "keywords": [ + "mess detection", + "mess detector", + "pdepend", + "phpmd", + "pmd" + ], + "time": "2016-04-04 11:52:04" + }, { "name": "phpspec/prophecy", "version": "v1.6.1", @@ -2360,6 +2465,45 @@ ], "time": "2016-06-17 09:04:28" }, + { + "name": "sebastian/finder-facade", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/finder-facade.git", + "reference": "2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9", + "reference": "2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9", + "shasum": "" + }, + "require": { + "symfony/finder": "~2.3|~3.0", + "theseer/fdomdocument": "~1.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.", + "homepage": "https://github.com/sebastianbergmann/finder-facade", + "time": "2016-02-17 07:02:23" + }, { "name": "sebastian/global-state", "version": "1.1.1", @@ -2457,6 +2601,57 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "time": "2016-01-28 13:25:10" }, + { + "name": "sebastian/phpcpd", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpcpd.git", + "reference": "24d9a880deadb0b8c9680e9cfe78e30b704225db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/24d9a880deadb0b8c9680e9cfe78e30b704225db", + "reference": "24d9a880deadb0b8c9680e9cfe78e30b704225db", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-timer": ">=1.0.6", + "sebastian/finder-facade": "~1.1", + "sebastian/version": "~1.0|~2.0", + "symfony/console": "~2.7|^3.0", + "theseer/fdomdocument": "~1.4" + }, + "bin": [ + "phpcpd" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Copy/Paste Detector (CPD) for PHP code.", + "homepage": "https://github.com/sebastianbergmann/phpcpd", + "time": "2016-04-17 19:32:49" + }, { "name": "sebastian/recursion-context", "version": "1.0.2", @@ -2595,6 +2790,84 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-02-04 12:56:52" }, + { + "name": "squizlabs/php_codesniffer", + "version": "2.6.1", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "fb72ed32f8418db5e7770be1653e62e0d6f5dd3d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/fb72ed32f8418db5e7770be1653e62e0d6f5dd3d", + "reference": "fb72ed32f8418db5e7770be1653e62e0d6f5dd3d", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "bin": [ + "scripts/phpcs", + "scripts/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "classmap": [ + "CodeSniffer.php", + "CodeSniffer/CLI.php", + "CodeSniffer/Exception.php", + "CodeSniffer/File.php", + "CodeSniffer/Fixer.php", + "CodeSniffer/Report.php", + "CodeSniffer/Reporting.php", + "CodeSniffer/Sniff.php", + "CodeSniffer/Tokens.php", + "CodeSniffer/Reports/", + "CodeSniffer/Tokenizers/", + "CodeSniffer/DocGenerators/", + "CodeSniffer/Standards/AbstractPatternSniff.php", + "CodeSniffer/Standards/AbstractScopeSniff.php", + "CodeSniffer/Standards/AbstractVariableSniff.php", + "CodeSniffer/Standards/IncorrectPatternException.php", + "CodeSniffer/Standards/Generic/Sniffs/", + "CodeSniffer/Standards/MySource/Sniffs/", + "CodeSniffer/Standards/PEAR/Sniffs/", + "CodeSniffer/Standards/PSR1/Sniffs/", + "CodeSniffer/Standards/PSR2/Sniffs/", + "CodeSniffer/Standards/Squiz/Sniffs/", + "CodeSniffer/Standards/Zend/Sniffs/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2016-05-30 22:24:32" + }, { "name": "symfony/browser-kit", "version": "v3.1.1", @@ -2818,6 +3091,66 @@ "homepage": "https://symfony.com", "time": "2016-06-06 11:42:41" }, + { + "name": "symfony/dependency-injection", + "version": "v3.1.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "4b9645f5870e0b4ab35cc5b528422049946e8bec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/4b9645f5870e0b4ab35cc5b528422049946e8bec", + "reference": "4b9645f5870e0b4ab35cc5b528422049946e8bec", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "symfony/config": "~2.8|~3.0", + "symfony/expression-language": "~2.8|~3.0", + "symfony/yaml": "~2.8|~3.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "https://symfony.com", + "time": "2016-06-14 11:18:07" + }, { "name": "symfony/dom-crawler", "version": "v3.1.1", @@ -3607,6 +3940,46 @@ "homepage": "https://symfony.com", "time": "2016-06-14 11:18:07" }, + { + "name": "theseer/fdomdocument", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/fDOMDocument.git", + "reference": "d9ad139d6c2e8edf5e313ffbe37ff13344cf0684" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/fDOMDocument/zipball/d9ad139d6c2e8edf5e313ffbe37ff13344cf0684", + "reference": "d9ad139d6c2e8edf5e313ffbe37ff13344cf0684", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "lib-libxml": "*", + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "lead" + } + ], + "description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.", + "homepage": "https://github.com/theseer/fDOMDocument", + "time": "2015-05-27 22:58:02" + }, { "name": "twig/extensions", "version": "v1.3.0", @@ -3811,7 +4184,8 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "soundasleep/html2text": 20 + "soundasleep/html2text": 20, + "phpmd/phpmd": 0 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/tasks/code_sniffer/MailPoet/Sniffs/ControlStructures/ControlSignatureSniff.php b/tasks/code_sniffer/MailPoet/Sniffs/ControlStructures/ControlSignatureSniff.php new file mode 100644 index 0000000000..80ebe23b9b --- /dev/null +++ b/tasks/code_sniffer/MailPoet/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -0,0 +1,59 @@ + + * @author Marc McIntyre + * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) { + throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found'); +} + +/** + * Verifies spacing of control statements. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood + * @author Marc McIntyre + * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class MailPoet_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff { + + /** + * If true, comments will be ignored if they are found in the code. + * + * @var boolean + */ + public $ignoreComments = true; + + /** + * Returns the patterns that this test wishes to verify. + * + * @return string[] + */ + protected function getPatterns() { + return array( + 'do {EOL...} while(...);EOL', + 'while(...) {EOL', + 'for(...) {EOL', + 'if(...) {EOL', + 'foreach(...) {EOL', + '} else if(...) {EOL', + '} elseif(...) {EOL', + '} else {EOL', + 'do {EOL', + ); + } +} diff --git a/tasks/code_sniffer/MailPoet/ruleset.xml b/tasks/code_sniffer/MailPoet/ruleset.xml new file mode 100644 index 0000000000..083447658e --- /dev/null +++ b/tasks/code_sniffer/MailPoet/ruleset.xml @@ -0,0 +1,123 @@ + + + MailPoet specific rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tasks/php_lint.sh b/tasks/php_lint.sh new file mode 100755 index 0000000000..0531d3f765 --- /dev/null +++ b/tasks/php_lint.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +error=false + +while test $# -gt 0; do + current=$1 + shift + + if [ ! -d $current ] && [ ! -f $current ] ; then + echo "Invalid directory or file: $current" + error=true + + continue + fi + + for file in `find $current -type f -name "*.php"` ; do + RESULTS=`php -l $file` + + if [ "$RESULTS" != "No syntax errors detected in $file" ] ; then + echo $RESULTS + error=true + fi + done +done + + +if [ "$error" = true ] ; then + exit 1 +else + exit 0 +fi