From d3f6a5460ea0dacc857e1de845d49813b3904b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sun, 28 Oct 2018 20:01:27 +0100 Subject: [PATCH] Add Code Sniffer --- Makefile | 36 ++++-- phpcs.xml.dist | 31 +++++ vendor-bin/code-sniffer/composer.json | 7 ++ vendor-bin/code-sniffer/composer.lock | 174 ++++++++++++++++++++++++++ 4 files changed, 240 insertions(+), 8 deletions(-) create mode 100644 phpcs.xml.dist create mode 100644 vendor-bin/code-sniffer/composer.json create mode 100644 vendor-bin/code-sniffer/composer.lock diff --git a/Makefile b/Makefile index 1d1bd8a2..2c1a13fb 100644 --- a/Makefile +++ b/Makefile @@ -13,12 +13,20 @@ help: #--------------------------------------------------------------------------- .PHONY: clean -clean: ## Clean all created artifacts +clean: ## Clean all created artifacts clean: git clean --exclude=.idea/ -ffdx +.PHONY: cs +CODE_SNIFFER=vendor-bin/code-sniffer/vendor/bin/phpcs +CODE_SNIFFER_FIX=vendor-bin/code-sniffer/vendor/bin/phpcbf +cs: ## Fixes CS +cs: $(CODE_SNIFFER) $(CODE_SNIFFER_FIX) + $(PHPNOGC) $(CODE_SNIFFER_FIX) || true + $(PHPNOGC) $(PHP_CS_FIXER) fix + .PHONY: build -build: ## Build the PHAR +build: ## Build the PHAR BOX=bin/box build: bin/php-scoper.phar @@ -28,26 +36,26 @@ build: bin/php-scoper.phar #--------------------------------------------------------------------------- .PHONY: test -test: ## Run all the tests +test: ## Run all the tests test: tc e2e .PHONY: tu PHPUNIT=bin/phpunit -tu: ## Run PHPUnit tests +tu: ## Run PHPUnit tests tu: bin/phpunit $(PHPBIN) $(PHPUNIT) .PHONY: tc -tc: ## Run PHPUnit tests with test coverage +tc: ## Run PHPUnit tests with test coverage tc: bin/phpunit vendor-bin/covers-validator/vendor clover.xml .PHONY: tm -tm: ## Run Infection (Mutation Testing) +tm: ## Run Infection (Mutation Testing) tm: bin/phpunit $(MAKE) e2e_020 .PHONY: e2e -e2e: ## Run end-to-end tests +e2e: ## Run end-to-end tests e2e: e2e_004 e2e_005 e2e_011 e2e_013 e2e_014 e2e_015 e2e_016 e2e_017 e2e_018 e2e_019 e2e_020 e2e_021 e2e_022 e2e_023 e2e_024 e2e_025 e2e_026 e2e_027 PHPSCOPER=bin/php-scoper.phar @@ -287,7 +295,7 @@ e2e_027: bin/php-scoper.phar fixtures/set027-laravel/vendor .PHONY: tb BLACKFIRE=blackfire -tb: ## Run Blackfire profiling +tb: ## Run Blackfire profiling tb: bin/php-scoper.phar vendor $(BLACKFIRE) --new-reference run $(PHPBIN) bin/php-scoper.phar add-prefix --output-dir=build/php-scoper --force --quiet @@ -314,6 +322,10 @@ vendor-bin/covers-validator/vendor: vendor-bin/covers-validator/composer.lock ve composer bin covers-validator install touch $@ +vendor-bin/code-sniffer/vendor: vendor-bin/code-sniffer/composer.lock vendor/bamarni + composer bin code-sniffer install + touch $@ + fixtures/set005/vendor: fixtures/set005/composer.lock composer --working-dir=fixtures/set005 install touch $@ @@ -429,3 +441,11 @@ clover.xml: src --coverage-clover=clover.xml \ --coverage-xml=dist/infection-coverage/coverage-xml \ --log-junit=dist/infection-coverage/phpunit.junit.xml + +$(CODE_SNIFFER): vendor-bin/code-sniffer/vendor + composer bin code-sniffer install + touch $@ + +$(CODE_SNIFFER_FIX): vendor-bin/code-sniffer/vendor + composer bin code-sniffer install + touch $@ diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 00000000..fc4263c6 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + fixtures + default_stub\.php + /vendor/ + /build/ + src + tests + + + + + + src/bootstrap\.php + src/functions\.php + + + + + + diff --git a/vendor-bin/code-sniffer/composer.json b/vendor-bin/code-sniffer/composer.json new file mode 100644 index 00000000..09c2b345 --- /dev/null +++ b/vendor-bin/code-sniffer/composer.json @@ -0,0 +1,7 @@ +{ + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "slevomat/coding-standard": "^4.8", + "squizlabs/php_codesniffer": "^3.3" + } +} diff --git a/vendor-bin/code-sniffer/composer.lock b/vendor-bin/code-sniffer/composer.lock new file mode 100644 index 00000000..a4e1c18f --- /dev/null +++ b/vendor-bin/code-sniffer/composer.lock @@ -0,0 +1,174 @@ +{ + "_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#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "b76196853c74fbbeb999118b474f56b1", + "packages": [], + "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.5.0", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "e749410375ff6fb7a040a68878c656c2e610b132" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132", + "reference": "e749410375ff6fb7a040a68878c656c2e610b132", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "^5.3|^7", + "squizlabs/php_codesniffer": "^2|^3" + }, + "require-dev": { + "composer/composer": "*", + "phpcompatibility/php-compatibility": "^9.0", + "sensiolabs/security-checker": "^4.1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "time": "2018-10-26T13:21:45+00:00" + }, + { + "name": "slevomat/coding-standard", + "version": "4.8.5", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "057f3f154cf4888b60eb4cdffadc509a3ae9dccd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/057f3f154cf4888b60eb4cdffadc509a3ae9dccd", + "reference": "057f3f154cf4888b60eb4cdffadc509a3ae9dccd", + "shasum": "" + }, + "require": { + "php": "^7.1", + "squizlabs/php_codesniffer": "^3.3.0" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "1.0.0", + "phing/phing": "2.16.1", + "phpstan/phpstan": "0.9.2", + "phpstan/phpstan-phpunit": "0.9.4", + "phpstan/phpstan-strict-rules": "0.9", + "phpunit/phpunit": "7.3.5" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "time": "2018-10-05T12:10:21+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e", + "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "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": "2018-09-23T23:08:17+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +}