Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Code Sniffer #272

Merged
merged 1 commit into from
Oct 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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 $@
Expand Down Expand Up @@ -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 $@
31 changes: 31 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset
name="Doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor-bin/code-sniffer/vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg value="ps"/>

<file>fixtures</file>
<exclude-pattern>default_stub\.php</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/build/</exclude-pattern>
<file>src</file>
<file>tests</file>

<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName"/>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName">
<exclude-pattern>src/bootstrap\.php</exclude-pattern>
<exclude-pattern>src/functions\.php</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint"/>
</ruleset>
7 changes: 7 additions & 0 deletions vendor-bin/code-sniffer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"slevomat/coding-standard": "^4.8",
"squizlabs/php_codesniffer": "^3.3"
}
}
174 changes: 174 additions & 0 deletions vendor-bin/code-sniffer/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.