From 6a94ab479e54d1d6c25ec2000c19b7e44a8b1266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Moy=C3=A1?= Date: Sun, 27 Sep 2020 16:52:10 -0300 Subject: [PATCH 1/3] Update PHP Codesniffer --- Dockerfile | 12 +- Executor.php | 135 +++++++++++++++++++ composer.json | 4 +- composer.lock | 366 +++++++++++++++++++++++++++++++++++--------------- engine.php | 4 +- 5 files changed, 399 insertions(+), 122 deletions(-) create mode 100644 Executor.php diff --git a/Dockerfile b/Dockerfile index e2af141..28ec97e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:edge +FROM alpine:3.12 RUN adduser -u 9000 -D app @@ -20,15 +20,9 @@ RUN apk add --no-cache \ php7-tokenizer \ php7-xml \ php7-xmlwriter \ - php7-zlib && \ - EXPECTED_SIGNATURE=$(php -r "echo file_get_contents('https://composer.github.io/installer.sig');") && \ - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ - ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") && \ - [ "$EXPECTED_SIGNATURE" = "$ACTUAL_SIGNATURE" ] || (echo "Invalid Composer installer signature"; exit 1) && \ - php composer-setup.php --quiet && \ - mv composer.phar /usr/local/bin/composer && \ - rm -r composer-setup.php ~/.composer + php7-zlib +COPY --from=composer /usr/bin/composer /usr/local/bin/composer COPY composer.json composer.lock ./ RUN apk add --no-cache git && \ diff --git a/Executor.php b/Executor.php new file mode 100644 index 0000000..af50508 --- /dev/null +++ b/Executor.php @@ -0,0 +1,135 @@ +config = $config; + $this->server = $server; + } + + public function queueDirectory($dir, $prefix = '') + { + chdir("/code"); + + if(isset($this->config['include_paths'])) { + $this->queueWithIncludePaths(); + } else { + $this->queuePaths($dir, $prefix, $this->config['exclude_paths']); + } + + $this->server->process_work(false); + } + + public function queueWithIncludePaths() { + foreach ($this->config['include_paths'] as $f) { + if ($f !== '.' and $f !== '..') { + if (is_dir($f)) { + $this->queuePaths("$f", "$f/"); + } else { + $this->filterByExtension($f); + } + } + } + } + + public function queuePaths($dir, $prefix = '', $exclusions = []) { + $dir = rtrim($dir, '\\/'); + + foreach (scandir($dir) as $f) { + if (in_array("$prefix$f", $exclusions)) { + continue; + } + + if ($f !== '.' and $f !== '..') { + if (is_dir("$dir/$f")) { + $this->queuePaths("$dir/$f", "$prefix$f/", $exclusions); + } else { + $this->filterByExtension($f, $prefix); + } + } + } + } + + public function filterByExtension($f, $prefix = '') { + foreach ($this->fileExtensions() as $file_extension) { + if (S::create($f)->endsWith($file_extension)) { + $prefix = ltrim($prefix, "\\/"); + $this->server->addwork(array("$prefix$f")); + } + } + } + + private function fileExtensions() { + $extensions = $this->config['config']['file_extensions']; + + if (empty($extensions)) { + return self::DEFAULT_EXTENSIONS; + } else { + return explode(",", $extensions); + } + } + + public function run($files) + { + try { + $resultFile = tempnam(sys_get_temp_dir(), 'phpcodesniffer'); + $config_args = array( '-s', '-p' ); + + if (isset($this->config['config']['ignore_warnings']) && $this->config['config']['ignore_warnings']) { + $config_args[] = '-n'; + } + + Timing::startTiming(); + + $runner = new Runner(); + $runner->config = new Config($config_args); + + if (isset($this->config['config']['standard'])) { + $runner->config->standards = explode(',', $this->config['config']['standard']); + } else { + $runner->config->standards = array('PSR1', 'PSR2'); + } + + if (isset($this->config['config']['encoding'])) { + $runner->config->encoding = $this->config['config']['encoding']; + } + + $runner->config->reports = array( 'json' => null ); + $runner->config->reportFile = $resultFile; + $runner->init(); + + $runner->reporter = new Reporter($runner->config); + + foreach ( $files as $file_path ) { + $file = new DummyFile( file_get_contents( $file_path ), $runner->ruleset, $runner->config ); + $file->path = $file_path; + + $runner->processFile( $file ); + } + + ob_start(); + + $runner->reporter->printReports(); + $report = ob_get_clean(); + + return $resultFile; + } catch (\Throwable $e) { + error_log("Exception: " . $e->getMessage() . " in " . $e->getFile() . "\n" . $e->getTraceAsString()); + return $e; + } + } +} diff --git a/composer.json b/composer.json index a7a445c..672a0d1 100644 --- a/composer.json +++ b/composer.json @@ -16,11 +16,11 @@ } }, "require": { - "squizlabs/php_codesniffer": "^2.9.1", + "squizlabs/php_codesniffer": "^3.5.6", "barracudanetworks/forkdaemon-php": "^1.0", "danielstjules/stringy": "^2.3", "drupal/coder": "^8.2", - "escapestudios/symfony2-coding-standard": "^2.10", + "escapestudios/symfony2-coding-standard": "^3.10", "wp-coding-standards/wpcs": "^1.0.0", "yiisoft/yii2-coding-standards": "^2.0", "magento/marketplace-eqp": "^1.0" diff --git a/composer.lock b/composer.lock index 06eafbf..6ac9fde 100644 --- a/composer.lock +++ b/composer.lock @@ -1,23 +1,23 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ca9866abf2d7c3279c42d023ad696abe", + "content-hash": "f93564adbeaee167745698d64f8db8af", "packages": [ { "name": "barracudanetworks/forkdaemon-php", - "version": "v1.1.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/barracudanetworks/forkdaemon-php.git", - "reference": "98307c172debec0ea982ef369634292d84bd5b2a" + "reference": "16c068748ce170ab167f288b116ac0d105f6185d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barracudanetworks/forkdaemon-php/zipball/98307c172debec0ea982ef369634292d84bd5b2a", - "reference": "98307c172debec0ea982ef369634292d84bd5b2a", + "url": "https://api.github.com/repos/barracudanetworks/forkdaemon-php/zipball/16c068748ce170ab167f288b116ac0d105f6185d", + "reference": "16c068748ce170ab167f288b116ac0d105f6185d", "shasum": "" }, "require": { @@ -40,7 +40,7 @@ "forking", "php" ], - "time": "2017-12-18T15:52:48+00:00" + "time": "2018-09-11T14:29:03+00:00" }, { "name": "danielstjules/stringy", @@ -100,31 +100,33 @@ }, { "name": "drupal/coder", - "version": "8.2.12", + "version": "8.3.10", "source": { "type": "git", - "url": "https://git.drupal.org/project/coder.git", - "reference": "984c54a7b1e8f27ff1c32348df69712afd86b17f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/klausi/coder/zipball/984c54a7b1e8f27ff1c32348df69712afd86b17f", - "reference": "984c54a7b1e8f27ff1c32348df69712afd86b17f", - "shasum": "" + "url": "https://git.drupalcode.org/project/coder.git", + "reference": "e1d71c6bb75b94f9ed00dceb2f4f6cb7e044723d" }, "require": { "ext-mbstring": "*", - "php": ">=5.4.0", - "squizlabs/php_codesniffer": ">=2.8.1 <3.0", - "symfony/yaml": ">=2.0.0" + "php": ">=7.0.8", + "sirbrillig/phpcs-variable-analysis": "^2.8", + "squizlabs/php_codesniffer": "^3.5.6", + "symfony/yaml": ">=2.0.5" }, "require-dev": { - "phpunit/phpunit": ">=3.7 <6" + "phpstan/phpstan": "^0.12.31", + "phpunit/phpunit": "^6.0 || ^7.0" }, "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "Drupal\\": "coder_sniffer/Drupal/", + "DrupalPractice\\": "coder_sniffer/DrupalPractice/" + } + }, "notification-url": "https://packagist.org/downloads/", "license": [ - "GPL-2.0+" + "GPL-2.0-or-later" ], "description": "Coder is a library to review Drupal code.", "homepage": "https://www.drupal.org/project/coder", @@ -133,29 +135,35 @@ "phpcs", "standards" ], - "time": "2017-03-18T10:28:49+00:00" + "time": "2020-09-03T19:59:53+00:00" }, { "name": "escapestudios/symfony2-coding-standard", - "version": "2.11.0", + "version": "3.11.0", "source": { "type": "git", "url": "https://github.com/djoos/Symfony-coding-standard.git", - "reference": "4aea10ad53d1952b2cfd8f7c9afe5e481dd574bc" + "reference": "78e3b0b6832c88cf7c0240b4abcd61430030d8c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/djoos/Symfony-coding-standard/zipball/4aea10ad53d1952b2cfd8f7c9afe5e481dd574bc", - "reference": "4aea10ad53d1952b2cfd8f7c9afe5e481dd574bc", + "url": "https://api.github.com/repos/djoos/Symfony-coding-standard/zipball/78e3b0b6832c88cf7c0240b4abcd61430030d8c3", + "reference": "78e3b0b6832c88cf7c0240b4abcd61430030d8c3", "shasum": "" }, "require": { - "squizlabs/php_codesniffer": "~2.0" + "squizlabs/php_codesniffer": "^3.3.1" + }, + "conflict": { + "squizlabs/php_codesniffer": "<3 || >=4" + }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^6.0 || ^7.0" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "3.x-dev" } }, "notification-url": "https://packagist.org/downloads/", @@ -165,22 +173,22 @@ "authors": [ { "name": "David Joos", - "email": "david.joos@escapestudios.com" + "email": "iam@davidjoos.com" }, { "name": "Community contributors", - "homepage": "https://github.com/djoos/Symfony2-coding-standard/graphs/contributors" + "homepage": "https://github.com/djoos/Symfony-coding-standard/graphs/contributors" } ], "description": "CodeSniffer ruleset for the Symfony 2+ coding standard", - "homepage": "https://github.com/djoos/Symfony2-coding-standard", + "homepage": "https://github.com/djoos/Symfony-coding-standard", "keywords": [ "Coding Standard", "Symfony2", "phpcs", "symfony" ], - "time": "2017-06-08T10:48:30+00:00" + "time": "2020-01-22T10:27:47+00:00" }, { "name": "magento/marketplace-eqp", @@ -196,66 +204,87 @@ ], "description": "A set of PHP_CodeSniffer rules and sniffs." }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.8.3", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "00b4fa3130faa26762c929989e3d958086c627f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/00b4fa3130faa26762c929989e3d958086c627f1", + "reference": "00b4fa3130faa26762c929989e3d958086c627f1", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "squizlabs/php_codesniffer": "^3.1" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4 || ^0.5 || ^0.6", + "limedeck/phpunit-detailed-printer": "^3.1 || ^4.0 || ^5.0", + "phpstan/phpstan": "^0.11.8", + "phpunit/phpunit": "^5.0 || ^6.5 || ^7.0 || ^8.0", + "sirbrillig/phpcs-import-detection": "^1.1" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "VariableAnalysis\\": "VariableAnalysis/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Sam Graham", + "email": "php-codesniffer-variableanalysis@illusori.co.uk" + }, + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A PHPCS sniff to detect problems with variables.", + "time": "2020-07-11T23:32:06+00:00" + }, { "name": "squizlabs/php_codesniffer", - "version": "2.9.1", + "version": "3.5.6", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" + "reference": "e97627871a7eab2f70e59166072a6b767d5834e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/e97627871a7eab2f70e59166072a6b767d5834e0", + "reference": "e97627871a7eab2f70e59166072a6b767d5834e0", "shasum": "" }, "require": { "ext-simplexml": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": ">=5.1.2" + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "bin": [ - "scripts/phpcs", - "scripts/phpcbf" + "bin/phpcs", + "bin/phpcbf" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "3.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" @@ -267,25 +296,89 @@ } ], "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", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", "standards" ], - "time": "2017-05-22T02:43:20+00:00" + "time": "2020-08-10T04:50:15+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5fa56b4074d1ae755beb55617ddafe6f5d78f665" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5fa56b4074d1ae755beb55617ddafe6f5d78f665", + "reference": "5fa56b4074d1ae755beb55617ddafe6f5d78f665", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-09-07T11:33:47+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.9.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", "shasum": "" }, "require": { @@ -297,7 +390,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -313,13 +410,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Gert de Pagter", "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for ctype functions", @@ -330,20 +427,34 @@ "polyfill", "portable" ], - "time": "2018-08-06T14:22:27+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.9.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8" + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", "shasum": "" }, "require": { @@ -355,7 +466,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -389,39 +504,57 @@ "portable", "shim" ], - "time": "2018-08-06T14:22:27+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/yaml", - "version": "v4.1.4", + "version": "v5.1.6", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "b832cc289608b6d305f62149df91529a2ab3c314" + "reference": "e147a68cb66a8b510f4b7481fe4da5b2ab65ec6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/b832cc289608b6d305f62149df91529a2ab3c314", - "reference": "b832cc289608b6d305f62149df91529a2ab3c314", + "url": "https://api.github.com/repos/symfony/yaml/zipball/e147a68cb66a8b510f4b7481fe4da5b2ab65ec6a", + "reference": "e147a68cb66a8b510f4b7481fe4da5b2ab65ec6a", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/console": "<3.4" + "symfony/console": "<4.4" }, "require-dev": { - "symfony/console": "~3.4|~4.0" + "symfony/console": "^4.4|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" }, + "bin": [ + "Resources/bin/yaml-lint" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -448,20 +581,34 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-08-18T16:52:46+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-09-27T03:44:28+00:00" }, { "name": "wp-coding-standards/wpcs", - "version": "1.0.0", + "version": "1.2.1", "source": { "type": "git", - "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", - "reference": "539c6d74e6207daa22b7ea754d6f103e9abb2755" + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/539c6d74e6207daa22b7ea754d6f103e9abb2755", - "reference": "539c6d74e6207daa22b7ea754d6f103e9abb2755", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c", + "reference": "f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c", "shasum": "" }, "require": { @@ -469,7 +616,7 @@ "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2" }, "require-dev": { - "phpcompatibility/php-compatibility": "*" + "phpcompatibility/php-compatibility": "^9.0" }, "suggest": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." @@ -491,25 +638,25 @@ "standards", "wordpress" ], - "time": "2018-07-25T18:10:35+00:00" + "time": "2018-12-18T09:43:51+00:00" }, { "name": "yiisoft/yii2-coding-standards", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-coding-standards.git", - "reference": "1047aaefcce4cfb83e4987110a573d19706bc50d" + "reference": "b76c3f58b54c37624f4b17582971e71981b71122" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-coding-standards/zipball/1047aaefcce4cfb83e4987110a573d19706bc50d", - "reference": "1047aaefcce4cfb83e4987110a573d19706bc50d", + "url": "https://api.github.com/repos/yiisoft/yii2-coding-standards/zipball/b76c3f58b54c37624f4b17582971e71981b71122", + "reference": "b76c3f58b54c37624f4b17582971e71981b71122", "shasum": "" }, "require": { "php": ">=5.4.0", - "squizlabs/php_codesniffer": ">=2.3.1 <3.0" + "squizlabs/php_codesniffer": ">=3.2" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -559,7 +706,7 @@ "framework", "yii" ], - "time": "2017-05-12T10:30:45+00:00" + "time": "2018-09-04T23:10:55+00:00" } ], "packages-dev": [], @@ -569,5 +716,6 @@ "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/engine.php b/engine.php index b86b006..ec8afa4 100644 --- a/engine.php +++ b/engine.php @@ -2,7 +2,7 @@ // Hooking into Composer's autoloader require_once __DIR__.'/vendor/autoload.php'; -require_once "Runner.php"; +require_once "Executor.php"; require_once "Sniffs.php"; use Sniffs\Sniffs; @@ -20,7 +20,7 @@ $server->max_children_set(3); $server->max_work_per_child_set(50); $server->store_result_set(true); -$runner = new Runner($config, $server); +$runner = new Executor($config, $server); $server->register_child_run(array($runner, "run")); $runner->queueDirectory("/code"); From 52ac61cc0298e988c13f8223fbda8d145aad2dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Moy=C3=A1?= Date: Sun, 27 Sep 2020 16:52:16 -0300 Subject: [PATCH 2/3] Update circleci --- .circleci/config.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..3468317 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,15 @@ +version: 2.1 + +jobs: + build: + machine: + docker_layer_caching: true + working_directory: ~/codeclimate/codeclimate-phpcodesniffer + steps: + - checkout + - run: + name: Build + command: make image +notify: + webhooks: + - url: https://cc-slack-proxy.herokuapp.com/circle From 48371afc50467462e3d14a8a8421d7ecabcbbe3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Moy=C3=A1?= Date: Sun, 27 Sep 2020 17:07:50 -0300 Subject: [PATCH 3/3] Address cc issues --- Executor.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Executor.php b/Executor.php index af50508..d559b61 100644 --- a/Executor.php +++ b/Executor.php @@ -6,6 +6,7 @@ use PHP_CodeSniffer\Reporter; use PHP_CodeSniffer\Files\DummyFile; use PHP_CodeSniffer\Util\Timing; + require_once __DIR__.'/vendor/squizlabs/php_codesniffer/autoload.php'; class Executor @@ -25,7 +26,7 @@ public function queueDirectory($dir, $prefix = '') { chdir("/code"); - if(isset($this->config['include_paths'])) { + if (isset($this->config['include_paths'])) { $this->queueWithIncludePaths(); } else { $this->queuePaths($dir, $prefix, $this->config['exclude_paths']); @@ -34,7 +35,8 @@ public function queueDirectory($dir, $prefix = '') $this->server->process_work(false); } - public function queueWithIncludePaths() { + public function queueWithIncludePaths() + { foreach ($this->config['include_paths'] as $f) { if ($f !== '.' and $f !== '..') { if (is_dir($f)) { @@ -46,7 +48,8 @@ public function queueWithIncludePaths() { } } - public function queuePaths($dir, $prefix = '', $exclusions = []) { + public function queuePaths($dir, $prefix = '', $exclusions = []) + { $dir = rtrim($dir, '\\/'); foreach (scandir($dir) as $f) { @@ -64,7 +67,8 @@ public function queuePaths($dir, $prefix = '', $exclusions = []) { } } - public function filterByExtension($f, $prefix = '') { + public function filterByExtension($f, $prefix = '') + { foreach ($this->fileExtensions() as $file_extension) { if (S::create($f)->endsWith($file_extension)) { $prefix = ltrim($prefix, "\\/"); @@ -73,7 +77,8 @@ public function filterByExtension($f, $prefix = '') { } } - private function fileExtensions() { + private function fileExtensions() + { $extensions = $this->config['config']['file_extensions']; if (empty($extensions)) { @@ -114,11 +119,11 @@ public function run($files) $runner->reporter = new Reporter($runner->config); - foreach ( $files as $file_path ) { - $file = new DummyFile( file_get_contents( $file_path ), $runner->ruleset, $runner->config ); + foreach ($files as $file_path) { + $file = new DummyFile(file_get_contents($file_path), $runner->ruleset, $runner->config); $file->path = $file_path; - $runner->processFile( $file ); + $runner->processFile($file); } ob_start(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy